API reference: @salmonui/data-grid/engine
EditMethodstype
import type { EditMethods } from '@salmonui/data-grid/engine';Also exported from @salmonui/data-grid/engine/edit.
type EditMethods<Row> = {
getDraft(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): EditDraft | undefined;
cellFlags(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): number;
rowFlags(ctx: ModuleContext<Row>, rowId: RowId): number;
getValue(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): unknown;
getDisplay(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): EditDisplay | undefined;
getEditedRow(ctx: ModuleContext<Row>, rowId: RowId): Row | undefined;
getErrors(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): readonly string[];
getRowErrors(ctx: ModuleContext<Row>, rowId: RowId): readonly string[];
isCellEditable(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): boolean;
getEditableColumnIds(ctx: ModuleContext<Row>, rowId: RowId): readonly ColumnId[];
getAddedRowPosition(ctx: ModuleContext<Row>, rowId: RowId): 'top' | 'bottom' | undefined;
nextEditableCell(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId, direction: 'next' | 'previous' | 'down' | 'up'): CellRef | null;
isRequired(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): boolean;
getBatchChanges(ctx: ModuleContext<Row>): EditBatchChanges<Row>;
getBatchPreview(ctx: ModuleContext<Row>): EditPreview;
previewWrite(ctx: ModuleContext<Row>, scope: 'active' | 'batch'): {
added: readonly RowId[];
changed: readonly {
rowId: RowId;
columnIds: readonly ColumnId[];
}[];
deleted: readonly RowId[];
};
hasUnsavedChanges(ctx: ModuleContext<Row>): boolean;
getSnapshot(ctx: ModuleContext<Row>): EditSnapshot;
whenSettled(ctx: ModuleContext<Row>): Promise<void>;
getLastWrite(ctx: ModuleContext<Row>): EditWriteOutcome<Row> | null;
getSubmittedWrite(ctx: ModuleContext<Row>): number;
};
| Name | Signature | Description |
|---|---|---|
getDraft | getDraft(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): EditDraft | undefined; | |
cellFlags | cellFlags(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): number; |
|
rowFlags | rowFlags(ctx: ModuleContext<Row>, rowId: RowId): number; |
|
getValue | getValue(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): unknown; | Draft value, else the row value (added rows included). |
getDisplay | getDisplay(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): EditDisplay | undefined; | Value and text of a draft-backed cell (dirty cells, added rows); stable identity. |
getEditedRow | getEditedRow(ctx: ModuleContext<Row>, rowId: RowId): Row | undefined; | The row with its drafts applied (added rows included), or undefined. |
getErrors | getErrors(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): readonly string[]; | |
getRowErrors | getRowErrors(ctx: ModuleContext<Row>, rowId: RowId): readonly string[]; | |
isCellEditable | isCellEditable(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): boolean; | |
getEditableColumnIds | getEditableColumnIds(ctx: ModuleContext<Row>, rowId: RowId): readonly ColumnId[]; | Visible editable columns of a row, in display order. |
getAddedRowPosition | getAddedRowPosition(ctx: ModuleContext<Row>, rowId: RowId): 'top' | 'bottom' | undefined; | Edge an added row renders at: the |
nextEditableCell | nextEditableCell(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId, direction: 'next' | 'previous' | 'down' | 'up'): CellRef | null; | Next editable cell for Tab / Shift+Tab / Enter / Shift+Enter, or null. |
isRequired | isRequired(ctx: ModuleContext<Row>, rowId: RowId, columnId: ColumnId): boolean; | |
getBatchChanges | getBatchChanges(ctx: ModuleContext<Row>): EditBatchChanges<Row>; | |
getBatchPreview | getBatchPreview(ctx: ModuleContext<Row>): EditPreview; | |
previewWrite | previewWrite(ctx: ModuleContext<Row>, scope: 'active' | 'batch'): {
added: readonly RowId[];
changed: readonly {
rowId: RowId;
columnIds: readonly ColumnId[];
}[];
deleted: readonly RowId[];
}; | Rows the next |
hasUnsavedChanges | hasUnsavedChanges(ctx: ModuleContext<Row>): boolean; | |
getSnapshot | getSnapshot(ctx: ModuleContext<Row>): EditSnapshot; | |
whenSettled | whenSettled(ctx: ModuleContext<Row>): Promise<void>; | Resolves when no write or async validation is pending. |
getLastWrite | getLastWrite(ctx: ModuleContext<Row>): EditWriteOutcome<Row> | null; | |
getSubmittedWrite | getSubmittedWrite(ctx: ModuleContext<Row>): number; | Token of the last write sent to the source (0 before the first); |