API reference: @salmonui/data-grid/engine
EditApiinterface
import type { EditApi } from '@salmonui/data-grid/engine';Also exported from @salmonui/data-grid/engine/edit.
interface EditApi<Row> {
startEdit(rowId?: RowId, field?: string): CommandResult;
save(): CommandResult;
saveCell(): CommandResult;
cancelEdit(): CommandResult;
setEditValue(rowId: RowId, field: string, value: unknown): CommandResult;
addRow(row?: Readonly<Record<string, unknown>>, index?: number): CommandResult;
deleteRows(rowIds?: RowId | readonly RowId[]): CommandResult;
updateRow(rowId: RowId, row: Readonly<Record<string, unknown>>): CommandResult;
updateCell(rowId: RowId, field: string, value: unknown): CommandResult;
setCellValue(rowId: RowId, field: string, value: unknown): CommandResult;
setRowData(rowId: RowId, row: Row): CommandResult;
applyChanges(changes: EditDataChanges<Row>): CommandResult;
getPendingChanges(): EditBatchChanges<Row>;
getBatchPreview(): EditPreview | undefined;
getEditSnapshot(): EditSnapshot | undefined;
hasUnsavedChanges(): boolean;
whenEditSettled(): Promise<void>;
validateBatch(): Promise<boolean>;
undo(): CommandResult;
redo(): CommandResult;
canUndo(): boolean;
canRedo(): boolean;
}
Edit methods. Columns are named by field or column id (the column id
wins); value maps (addRow, updateRow) are keyed the same way.
| Name | Signature | Description |
|---|---|---|
startEdit | startEdit(rowId?: RowId, field?: string): CommandResult; | Row and dialog mode edit the row, batch and cell mode the cell (default: first editable). Without a row id, the first selected row. |
save | save(): CommandResult; | Saves the edit: commits the active row or cell; in batch mode saves every pending change. |
saveCell | saveCell(): CommandResult; | Commits the active editor only: the row in row and dialog mode, the cell in batch and cell mode (batch mode keeps the change pending). |
cancelEdit | cancelEdit(): CommandResult; | Discards the active editor; in batch mode without an open editor, every pending change. |
setEditValue | setEditValue(rowId: RowId, field: string, value: unknown): CommandResult; | Sets the draft of the active editor (or of any editable cell). |
addRow | addRow(row?: Readonly<Record<string, unknown>>, index?: number): CommandResult; | Adds a row (and edits it). |
deleteRows | deleteRows(rowIds?: RowId | readonly RowId[]): CommandResult; | Batch mode marks the rows; other modes write at once. Without ids, the selected rows. |
updateRow | updateRow(rowId: RowId, row: Readonly<Record<string, unknown>>): CommandResult; | Validates and writes the values. |
updateCell | updateCell(rowId: RowId, field: string, value: unknown): CommandResult; | Edits a cell as a user would: batch mode keeps a draft; other modes write at once. |
setCellValue | setCellValue(rowId: RowId, field: string, value: unknown): CommandResult; | Silent data update of one cell (no edit lifecycle or validation). Local data sources only. |
setRowData | setRowData(rowId: RowId, row: Row): CommandResult; | Silent replacement of a row (no edit lifecycle or validation). Local data sources only. |
applyChanges | applyChanges(changes: EditDataChanges<Row>): CommandResult; | Silent bulk data update (no edit lifecycle or validation). Local data sources only. |
getPendingChanges | getPendingChanges(): EditBatchChanges<Row>; | Added, changed, and deleted rows not saved yet. |
getBatchPreview | getBatchPreview(): EditPreview | undefined; | |
getEditSnapshot | getEditSnapshot(): EditSnapshot | undefined; | |
hasUnsavedChanges | hasUnsavedChanges(): boolean; | |
whenEditSettled | whenEditSettled(): Promise<void>; | Resolves when pending writes and async validators settled. |
validateBatch | validateBatch(): Promise<boolean>; | Validates every pending change without saving and publishes the errors; resolves true when everything is valid once async validators settled. |
undo | undo(): CommandResult; | Reverts the last edit action (needs |
redo | redo(): CommandResult; | Re-applies the last undone action. |
canUndo | canUndo(): boolean; | |
canRedo | canRedo(): boolean; |