API reference: @salmonui/data-grid
DataGridEditApiinterface
import type { DataGridEditApi } from '@salmonui/data-grid';interface DataGridEditApi<Row> extends DataGridClipboardApi {
startEdit(rowId?: RowId, field?: string): CommandResult;
save(): CommandResult;
saveCell(): CommandResult;
cancelEdit(): 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;
fillSelection(rowId: RowId, field: string): CommandResult;
}
Editing methods of the DataGrid instance.
| Name | Signature | Description |
|---|---|---|
startEdit | startEdit(rowId?: RowId, field?: string): CommandResult; | Row and dialog mode edit the row, batch and cell mode the cell. Without a row id: the first selected row. |
save | save(): CommandResult; | Saves: the active row or cell; in batch mode every pending change. |
saveCell | saveCell(): CommandResult; | Commits the active editor only (batch mode keeps the change pending). |
cancelEdit | cancelEdit(): CommandResult; | Discards the active editor; in batch mode without an open editor, every pending change. |
addRow | addRow(row?: Readonly<Record<string, unknown>>, index?: number): CommandResult; | Index 0 adds at the top, at or past the end at the bottom. |
deleteRows | deleteRows(rowIds?: RowId | readonly RowId[]): CommandResult; | Without ids: the selected rows. Batch mode marks the rows until save. |
updateRow | updateRow(rowId: RowId, row: Readonly<Record<string, unknown>>): CommandResult; | |
updateCell | updateCell(rowId: RowId, field: string, value: unknown): CommandResult; | Edits a cell as a user would (draft in batch mode). |
setCellValue | setCellValue(rowId: RowId, field: string, value: unknown): CommandResult; | Silent data updates without the edit lifecycle (local sources). |
setRowData | setRowData(rowId: RowId, row: Row): CommandResult; | |
applyChanges | applyChanges(changes: EditDataChanges<Row>): CommandResult; | |
getPendingChanges | getPendingChanges(): EditBatchChanges<Row>; | |
getBatchPreview | getBatchPreview(): EditPreview | undefined; | |
getEditSnapshot | getEditSnapshot(): EditSnapshot | undefined; | |
hasUnsavedChanges | hasUnsavedChanges(): boolean; | |
whenEditSettled | whenEditSettled(): Promise<void>; | |
validateBatch | validateBatch(): Promise<boolean>; | Validates every pending change without saving; resolves true when valid. |
undo | undo(): CommandResult; | Undoes the last edit (needs |
redo | redo(): CommandResult; | |
fillSelection | fillSelection(rowId: RowId, field: string): CommandResult; | Fills the selected cell range's content over the range extended to |
copyinherited | copy: (options?: DataGridCopyOptions | undefined) => CommandResult; | Copies the cell range, else the selected rows, else the focused cell to
the system clipboard (drafts included). Falls back to a copy dialog when
the browser blocks clipboard access. |
pasteinherited | paste: (text?: string | undefined) => CommandResult; | Pastes TSV |