Documentation

@kanunilabs/datagrid-enterprise


@kanunilabs/datagrid-enterprise / CrudHandlers

Interface: CrudHandlers<TRow>

Per-operation persistence — one call per affected ROW, which is the shape a REST or SQL back end actually wants (POST /orders, PATCH /orders/7, DELETE /orders/7). Supplying any of these switches saveChanges() off the batch onSave path; a grid that had to reduce a batch into three arrays and fan it out itself was the single most common thing apps rewrote by hand.

Every handler may reject. A rejection fails the WHOLE save and leaves the changes pending, so nothing the user typed is lost because row 3 of 10 hit a constraint. Handlers already applied are not rolled back — the grid does not know how, and pretending otherwise would be worse than saying so.

Type Parameters

TRow

TRow = GridRowData

Properties

insert?

optional insert?: (values) => void | TRow | Promise<void | TRow>

Persist a new row. Return the stored row to adopt the server's version of it (its real primary key, defaults, computed columns).

Parameters

values

Record<string, unknown>

Returns

void | TRow | Promise<void | TRow>


remove?

optional remove?: (key, row) => void | Promise<void>

Parameters

key

RowKey

row

TRow | undefined

Returns

void | Promise<void>


update?

optional update?: (key, values, row) => void | TRow | Promise<void | TRow>

values holds the CHANGED columns only, not the whole row.

Parameters

key

RowKey

values

Record<string, unknown>

row

TRow | undefined

Returns

void | TRow | Promise<void | TRow>