API reference: @salmonui/data-grid/engine
DataGridApiinterface
import type { DataGridApi } from '@salmonui/data-grid/engine';interface DataGridApi<Row> {
readonly engine: DataGridEngine<Row>;
getColumn(fieldOrId: string): CompiledColumn<Row> | undefined;
getColumns(): readonly CompiledColumn<Row>[];
getVisibleColumns(): readonly CompiledColumn<Row>[];
getHiddenColumns(): readonly CompiledColumn<Row>[];
getColumnAt(index: number): CompiledColumn<Row> | undefined;
getColumnIndex(fieldOrId: string): number;
showColumns(fieldsOrIds: string | readonly string[]): CommandResult;
hideColumns(fieldsOrIds: string | readonly string[]): CommandResult;
getViewRows(): readonly Row[];
getFilteredRows(): readonly Row[];
getRow(rowId: RowId): Row | undefined;
getRowInfo(rowId: RowId): RowSnapshot<Row> | undefined;
getRowIndex(rowId: RowId): number;
getRowIdAt(index: number): RowId | undefined;
getCell(rowId: RowId, field: string): CellSnapshot | undefined;
getDataSource(): DataSource<Row>;
getPrimaryKeyFields(): readonly string[];
sortColumn(field: string, direction: 'asc' | 'desc', options?: {
readonly multiple?: boolean;
}): CommandResult;
removeSort(field: string): CommandResult;
clearSorting(): CommandResult;
filterColumn(field: string, operator: string, value: Json, options?: FilterColumnOptions): CommandResult;
clearFiltering(fields?: string | readonly string[]): CommandResult;
removeFilter(field: string): CommandResult;
getColumnFacet(field: string, options?: FacetOptions): ColumnFacet | undefined;
search(text: string): CommandResult;
clearSearch(): CommandResult;
goToPage(page: number): CommandResult;
setPageSize(pageSize: number): CommandResult;
getPageInfo(): PageInfo | undefined;
groupColumn(field: string, index?: number): CommandResult;
ungroupColumn(field: string): CommandResult;
clearGrouping(): CommandResult;
toggleGroup(group: GroupTarget, expanded?: boolean): CommandResult;
expandAllGroups(): CommandResult;
collapseAllGroups(): CommandResult;
getGroup(rowId: RowId): GroupRowSnapshot | undefined;
getAggregates(groupId?: RowId): AggregateValues | undefined;
refresh(): void;
dispose(): void;
}
Imperative DataGrid API over an engine (re-exported by @salmonui/data-grid as
DataGridCoreApi and extended there). Every method that takes a column accepts
a field or a column id: the column id wins, else the first leaf with that
field. Mutating methods dispatch a serializable command and return its
CommandResult; read methods return engine-owned frozen values or raw row
references.
| Name | Signature | Description |
|---|---|---|
engine | readonly engine: DataGridEngine<Row>; | |
getColumn | getColumn(fieldOrId: string): CompiledColumn<Row> | undefined; | Leaf column by column id, else the first leaf with that |
getColumns | getColumns(): readonly CompiledColumn<Row>[]; | Every leaf column in definition order, including hidden ones. |
getVisibleColumns | getVisibleColumns(): readonly CompiledColumn<Row>[]; | Visible leaves in runtime order. |
getHiddenColumns | getHiddenColumns(): readonly CompiledColumn<Row>[]; | Leaves hidden at runtime, in definition order. |
getColumnAt | getColumnAt(index: number): CompiledColumn<Row> | undefined; | Visible leaf at an index of |
getColumnIndex | getColumnIndex(fieldOrId: string): number; | Index of a column in |
showColumns | showColumns(fieldsOrIds: string | readonly string[]): CommandResult; | |
hideColumns | hideColumns(fieldsOrIds: string | readonly string[]): CommandResult; | |
getViewRows | getViewRows(): readonly Row[]; | Rows of the current view (after the query pipeline), as raw references. |
getFilteredRows | getFilteredRows(): readonly Row[]; | Rows passing search and every filter, in sort order, across every page,
as raw references. Without the
|
getRow | getRow(rowId: RowId): Row | undefined; | |
getRowInfo | getRowInfo(rowId: RowId): RowSnapshot<Row> | undefined; | |
getRowIndex | getRowIndex(rowId: RowId): number; | Visible index of a row, or -1. |
getRowIdAt | getRowIdAt(index: number): RowId | undefined; | Row id at a visible index (the inverse of |
getCell | getCell(rowId: RowId, field: string): CellSnapshot | undefined; | |
getDataSource | getDataSource(): DataSource<Row>; | |
getPrimaryKeyFields | getPrimaryKeyFields(): readonly string[]; |
|
sortColumn | sortColumn(field: string, direction: 'asc' | 'desc', options?: {
readonly multiple?: boolean;
}): CommandResult; |
|
removeSort | removeSort(field: string): CommandResult; | |
clearSorting | clearSorting(): CommandResult; | |
filterColumn | filterColumn(field: string, operator: string, value: Json, options?: FilterColumnOptions): CommandResult; | An array value with a scalar operator ORs one condition per value. Needs the |
clearFiltering | clearFiltering(fields?: string | readonly string[]): CommandResult; | Clears every filter, or the filters of the given columns. |
removeFilter | removeFilter(field: string): CommandResult; | |
getColumnFacet | getColumnFacet(field: string, options?: FacetOptions): ColumnFacet | undefined; | Distinct values with counts for checkbox / Excel filters, or undefined without the |
search | search(text: string): CommandResult; | Searches with the |
clearSearch | clearSearch(): CommandResult; | |
goToPage | goToPage(page: number): CommandResult; | Needs the |
setPageSize | setPageSize(pageSize: number): CommandResult; | |
getPageInfo | getPageInfo(): PageInfo | undefined; | Pager model, or undefined without the |
groupColumn | groupColumn(field: string, index?: number): CommandResult; | Needs the |
ungroupColumn | ungroupColumn(field: string): CommandResult; | |
clearGrouping | clearGrouping(): CommandResult; | |
toggleGroup | toggleGroup(group: GroupTarget, expanded?: boolean): CommandResult; | Toggles (or sets) one group by row id, path key, or path. |
expandAllGroups | expandAllGroups(): CommandResult; | |
collapseAllGroups | collapseAllGroups(): CommandResult; | |
getGroup | getGroup(rowId: RowId): GroupRowSnapshot | undefined; | Caption or footer snapshot of a group row id, or undefined. |
getAggregates | getAggregates(groupId?: RowId): AggregateValues | undefined; | Without an argument the footer aggregates (undefined without the
|
refresh | refresh(): void; | Re-reads the data with the current query and keeps the grid state: |
dispose | dispose(): void; |