View as Markdown

API reference: @salmonui/data-grid

DataGridEditorContextinterface

import type { DataGridEditorContext } from '@salmonui/data-grid';
interface DataGridEditorContext<Row> {
    readonly value: unknown;
    setValue(value: unknown): void;
    save(): void;
    cancel(): void;
    readonly row: Row;
    readonly rowId: RowId;
    readonly field: string;
    readonly column: DataGridColumnInfo<Row>;
    readonly errors: readonly string[];
    readonly isNew: boolean;
    readonly placement: 'cell' | 'dialog';
    readonly editorProps: DataGridEditorProps;
    readonly inputProps: DataGridEditorInputProps;
}

Context of column renderEditor.

DataGridEditorContext members (13)
NameSignatureDescription
valuereadonly value: unknown;

The current draft value.

setValuesetValue(value: unknown): void;

Sets the draft (the column parser converts strings; dates as ISO strings or Date).

savesave(): void;

Commits like Enter (row: the row; batch and cell: the cell).

cancelcancel(): void;
rowreadonly row: Row;

The row with its drafts applied.

rowIdreadonly rowId: RowId;
fieldreadonly field: string;
columnreadonly column: DataGridColumnInfo<Row>;
errorsreadonly errors: readonly string[];
isNewreadonly isNew: boolean;
placementreadonly placement: 'cell' | 'dialog';

Where the editor renders.

editorPropsreadonly editorProps: DataGridEditorProps;
inputPropsreadonly inputProps: DataGridEditorInputProps;

Spread onto the focusable element: id, aria-invalid / aria-describedby / aria-required, autofocus. The editing keys are handled by the editor wrapper.