API reference: @salmonui/data-grid/engine
DataGridEngineinterface
import type { DataGridEngine } from '@salmonui/data-grid/engine';Also exported from @salmonui/data-grid.
interface DataGridEngine<Row> {
readonly id: string;
getSnapshot(): DataGridSnapshot<Row>;
getServerSnapshot(): DataGridSnapshot<Row>;
subscribe(listener: () => void): () => void;
select<T>(selector: (snapshot: DataGridSnapshot<Row>) => T): T;
subscribeSelector<T>(selector: (snapshot: DataGridSnapshot<Row>) => T, listener: (value: T) => void, isEqual?: (a: T, b: T) => boolean): () => void;
subscribeCell(rowId: RowId, columnId: ColumnId, listener: () => void): () => void;
subscribeRow(rowId: RowId, listener: () => void): () => void;
subscribeHeader(columnId: ColumnId, listener: () => void): () => void;
subscribeModule(name: string, listener: () => void): () => void;
getCellSnapshot(rowId: RowId, columnId: ColumnId): CellSnapshot | undefined;
getRowSnapshot(rowId: RowId): RowSnapshot<Row> | undefined;
getHeaderSnapshot(columnId: ColumnId): HeaderSnapshot | undefined;
getModuleState<T = unknown>(name: string): T | undefined;
getSelector(moduleName: string, selectorName: string): ((snapshot: DataGridSnapshot<Row>) => unknown) | undefined;
getRow(rowId: RowId): Row | undefined;
getRowIndex(rowId: RowId): number;
getRowAt(index: number): Row | undefined;
getRowIdAt(index: number): RowId | undefined;
getCellValue(rowId: RowId, columnId: ColumnId): unknown;
getDataSource(): DataSource<Row>;
setColumns(columns: readonly ColumnDef<Row>[]): void;
setLocale(next: {
readonly locale?: string;
readonly currency?: string;
readonly timeZone?: string | undefined;
readonly direction?: 'ltr' | 'rtl';
}): boolean;
dispatch(command: DataGridCommand): CommandResult;
hasCommand(type: string): boolean;
batch(run: () => void): void;
onBeforeCommand(listener: (event: BeforeCommandEvent) => boolean | string | void): () => void;
onCommand(listener: (event: CommandEvent) => void): () => void;
getCommandLog(): readonly DataGridCommand[];
getInstrumentation(): DataGridInstrumentation | null;
connect(): () => void;
reload(): void;
refresh(): void;
readonly disposed: boolean;
dispose(): void;
}
| Name | Signature | Description |
|---|---|---|
id | readonly id: string; | |
getSnapshot | getSnapshot(): DataGridSnapshot<Row>; | |
getServerSnapshot | getServerSnapshot(): DataGridSnapshot<Row>; | |
subscribe | subscribe(listener: () => void): () => void; | |
select | select<T>(selector: (snapshot: DataGridSnapshot<Row>) => T): T; | |
subscribeSelector | subscribeSelector<T>(selector: (snapshot: DataGridSnapshot<Row>) => T, listener: (value: T) => void, isEqual?: (a: T, b: T) => boolean): () => void; | |
subscribeCell | subscribeCell(rowId: RowId, columnId: ColumnId, listener: () => void): () => void; | |
subscribeRow | subscribeRow(rowId: RowId, listener: () => void): () => void; | |
subscribeHeader | subscribeHeader(columnId: ColumnId, listener: () => void): () => void; | |
subscribeModule | subscribeModule(name: string, listener: () => void): () => void; | |
getCellSnapshot | getCellSnapshot(rowId: RowId, columnId: ColumnId): CellSnapshot | undefined; | |
getRowSnapshot | getRowSnapshot(rowId: RowId): RowSnapshot<Row> | undefined; | |
getHeaderSnapshot | getHeaderSnapshot(columnId: ColumnId): HeaderSnapshot | undefined; | |
getModuleState | getModuleState<T = unknown>(name: string): T | undefined; | |
getSelector | getSelector(moduleName: string, selectorName: string): ((snapshot: DataGridSnapshot<Row>) => unknown) | undefined; | |
getRow | getRow(rowId: RowId): Row | undefined; | Raw row by id (source rows, including rows filtered out of the view). |
getRowIndex | getRowIndex(rowId: RowId): number; | Visible index of a row, or -1. |
getRowAt | getRowAt(index: number): Row | undefined; | |
getRowIdAt | getRowIdAt(index: number): RowId | undefined; | |
getCellValue | getCellValue(rowId: RowId, columnId: ColumnId): unknown; | |
getDataSource | getDataSource(): DataSource<Row>; | |
setColumns | setColumns(columns: readonly ColumnDef<Row>[]): void; | Recompiles only when the array identity or a definition identity changes. |
setLocale | setLocale(next: {
readonly locale?: string;
readonly currency?: string;
readonly timeZone?: string | undefined;
readonly direction?: 'ltr' | 'rtl';
}): boolean; | Changes the locale, currency, time zone, or direction at runtime. A format change recompiles the column formatters once
and re-runs the pipeline (collation follows the locale); a direction
change updates |
dispatch | dispatch(command: DataGridCommand): CommandResult; | |
hasCommand | hasCommand(type: string): boolean; | Whether a registered module declares the command type (UI commands probe it before dispatching). |
batch | batch(run: () => void): void; | |
onBeforeCommand | onBeforeCommand(listener: (event: BeforeCommandEvent) => boolean | string | void): () => void; | |
onCommand | onCommand(listener: (event: CommandEvent) => void): () => void; | |
getCommandLog | getCommandLog(): readonly DataGridCommand[]; | |
getInstrumentation | getInstrumentation(): DataGridInstrumentation | null; | |
connect | connect(): () => void; | With |
reload | reload(): void; | Re-reads the data source with the current query (retry after a data error). Before |
refresh | refresh(): void; | Refresh: drops the row and cell snapshot caches,
invalidates the source cache ( |
disposed | readonly disposed: boolean; | |
dispose | dispose(): void; |