API reference: @salmonui/data-grid
DataGridPropsinterface
import type { DataGridProps } from '@salmonui/data-grid';interface DataGridProps<Row> extends DataGridChromeProps<Row>, DataGridQueryProps, DataGridEditProps<Row>, DataGridOutputProps<Row>, DataGridAdaptiveProps, DataGridDetailProps<Row>, DataGridRowPinningProps<Row>, DataGridDataUiProps<Row>, DataGridFilterBuilderProps, DataGridTreeProps<Row> {
data?: readonly Row[] | DataSource<Row>;
columns?: readonly DataGridColumn<Row>[];
children?: ReactNode;
getRowId?: (row: Row) => RowId | number;
modules?: readonly DataGridModule<Row>[];
features?: readonly DataGridFeature[];
locale?: string;
timeZone?: string;
currency?: string;
dir?: 'ltr' | 'rtl' | 'auto';
height?: number | string;
width?: number | string;
rowHeight?: number;
getRowHeight?: (row: Row) => number;
estimatedRowHeight?: number;
headerHeight?: number;
defaultColumnWidth?: number;
virtualization?: boolean | DataGridVirtualization;
infiniteScroll?: boolean | DataGridInfiniteScroll<Row>;
renderLoadingRow?: (ctx: DataGridLoadingRowContext) => ReactNode;
initialRows?: number;
initialColumns?: number;
textWrap?: DataGridTextWrap;
gridLines?: DataGridLines;
overflow?: DataGridOverflow;
highlightOnHover?: boolean;
striped?: boolean;
resizable?: boolean;
resizeMode?: 'normal' | 'auto';
reorderable?: boolean;
onBeforeColumnVisibilityChange?: (event: DataGridColumnVisibilityChangeEvent) => void;
onColumnVisibilityChange?: (event: DataGridColumnVisibilityChangeEvent) => void;
onBeforeColumnReorder?: (event: DataGridColumnReorderEvent) => void;
onColumnReorder?: (event: DataGridColumnReorderEvent) => void;
grouping?: boolean | DataGridGrouping<Row>;
onBeforeGroupChange?: (event: DataGridGroupChangeEvent) => void;
onGroupChange?: (event: DataGridGroupChangeEvent) => void;
onBeforeGroupToggle?: (event: DataGridGroupToggleEvent<Row>) => void;
onGroupToggle?: (event: DataGridGroupToggleEvent<Row>) => void;
aggregates?: readonly DataGridAggregateRow<Row>[];
aggregateScope?: 'page' | 'all';
renderRow?: (ctx: DataGridRowContext<Row>) => ReactNode;
renderEmpty?: (ctx: DataGridEmptyContext) => ReactNode;
renderError?: (ctx: DataGridDataErrorContext) => ReactNode;
onViewChange?: (event: DataGridViewChangeEvent) => void;
getRowProps?: (row: Row, rowIndex: number, ctx: {
readonly tree?: DataGridTreeContext;
}) => DataGridElementProps | undefined;
rowClassName?: (row: Row, rowIndex: number) => string | undefined;
getCellProps?: (ctx: DataGridCellContext<Row>) => DataGridElementProps | undefined;
className?: string;
style?: CSSProperties;
classNames?: Partial<Record<DataGridPart, string>>;
styles?: Partial<Record<DataGridPart, CSSProperties>>;
icons?: DataGridIcons | undefined;
ref?: Ref<DataGridApi<Row>>;
id?: string;
'aria-label'?: string;
'aria-labelledby'?: string;
'aria-describedby'?: string;
onWarning?: (warning: DataGridWarning) => void;
onReady?: (api: DataGridApi<Row>) => void;
selection?: boolean | DataGridSelection;
onBeforeSelectionChange?: (event: DataGridSelectionChangeEvent<Row>) => void;
onSelectionChange?: (event: DataGridSelectionChangeEvent<Row>) => void;
keyBindings?: Readonly<Record<string, readonly string[]>>;
onKeyDown?: (ctx: DataGridKeyDownContext) => void;
localeText?: DataGridLocaleText;
persistState?: boolean | DataGridPersistState;
}
| Name | Signature | Description |
|---|---|---|
dataoptional | data?: readonly Row[] | DataSource<Row>; | Rows (reactive: a new array replaces the rows) or a |
columnsoptional | columns?: readonly DataGridColumn<Row>[]; | Column definitions; |
childrenoptional | children?: ReactNode; |
|
getRowIdoptional | getRowId?: (row: Row) => RowId | number; | Row identity. Default: the |
modulesoptional | modules?: readonly DataGridModule<Row>[]; | Extra core modules (initial only). |
featuresoptional | features?: readonly DataGridFeature[]; | Salmon. Render features to use
synchronously, from |
localeoptional | locale?: string; | |
timeZoneoptional | timeZone?: string; | IANA time zone for date formatting. Set it for SSR: server and client must format identically. |
currencyoptional | currency?: string; | |
diroptional | dir?: 'ltr' | 'rtl' | 'auto'; | Text direction. |
heightoptional | height?: number | string; | Viewport height: px, any CSS length ( |
widthoptional | width?: number | string; | |
rowHeightoptional | rowHeight?: number; | Fixed row height in px. Default 36. |
getRowHeightoptional | getRowHeight?: (row: Row) => number; | Per-row fixed height. |
estimatedRowHeightoptional | estimatedRowHeight?: number; | Enables measured row heights with this estimate (variable content, templates, wrapping). |
headerHeightoptional | headerHeight?: number; | Header row height in px (per stacked level). Default 40. |
defaultColumnWidthoptional | defaultColumnWidth?: number; | Width of columns without |
virtualizationoptional | virtualization?: boolean | DataGridVirtualization; | Row and column virtualization; |
infiniteScrolloptional | infiniteScroll?: boolean | DataGridInfiniteScroll<Row>; | Infinite scrolling for remote sources: rows load in blocks as the viewport approaches them. |
renderLoadingRowoptional | renderLoadingRow?: (ctx: DataGridLoadingRowContext) => ReactNode; | Placeholder row while its block loads, or after the load failed. Default: the loading text, or the error and a Retry button. |
initialRowsoptional | initialRows?: number; | Rows in the deterministic server/initial range. Default 20. |
initialColumnsoptional | initialColumns?: number; | Center columns in the deterministic server/initial range. Default 20. |
textWrapoptional | textWrap?: DataGridTextWrap; | |
gridLinesoptional | gridLines?: DataGridLines; | |
overflowoptional | overflow?: DataGridOverflow; | Default text overflow of every column. Default |
highlightOnHoveroptional | highlightOnHover?: boolean; | Row hover highlight. Default true. |
stripedoptional | striped?: boolean; | Alternate row shading. Default true. |
resizableoptional | resizable?: boolean; | Pointer and keyboard column resize. Default false; column |
resizeModeoptional | resizeMode?: 'normal' | 'auto'; | Column fit. |
reorderableoptional | reorderable?: boolean; | Pointer and keyboard column reorder. Default false; column |
onBeforeColumnVisibilityChangeoptional | onBeforeColumnVisibilityChange?: (event: DataGridColumnVisibilityChangeEvent) => void; | |
onColumnVisibilityChangeoptional | onColumnVisibilityChange?: (event: DataGridColumnVisibilityChangeEvent) => void; | |
onBeforeColumnReorderoptional | onBeforeColumnReorder?: (event: DataGridColumnReorderEvent) => void; | |
onColumnReorderoptional | onColumnReorder?: (event: DataGridColumnReorderEvent) => void; | |
groupingoptional | grouping?: boolean | DataGridGrouping<Row>; |
|
onBeforeGroupChangeoptional | onBeforeGroupChange?: (event: DataGridGroupChangeEvent) => void; | |
onGroupChangeoptional | onGroupChange?: (event: DataGridGroupChangeEvent) => void; | |
onBeforeGroupToggleoptional | onBeforeGroupToggle?: (event: DataGridGroupToggleEvent<Row>) => void; | |
onGroupToggleoptional | onGroupToggle?: (event: DataGridGroupToggleEvent<Row>) => void; | |
aggregatesoptional | aggregates?: readonly DataGridAggregateRow<Row>[]; | Aggregate rows (or |
aggregateScopeoptional | aggregateScope?: 'page' | 'all'; | With paging: |
renderRowoptional | renderRow?: (ctx: DataGridRowContext<Row>) => ReactNode; | |
renderEmptyoptional | renderEmpty?: (ctx: DataGridEmptyContext) => ReactNode; | |
renderErroroptional | renderError?: (ctx: DataGridDataErrorContext) => ReactNode; | Body content while the data source failed to load. Default: the error message and a Retry button. |
onViewChangeoptional | onViewChange?: (event: DataGridViewChangeEvent) => void; | Once per committed change of the displayed rows; never on scroll, focus, selection, or expansion. |
getRowPropsoptional | getRowProps?: (row: Row, rowIndex: number, ctx: {
readonly tree?: DataGridTreeContext;
}) => DataGridElementProps | undefined; | Called for rendered rows only; |
rowClassNameoptional | rowClassName?: (row: Row, rowIndex: number) => string | undefined; | |
getCellPropsoptional | getCellProps?: (ctx: DataGridCellContext<Row>) => DataGridElementProps | undefined; | Called for rendered cells only. |
classNameoptional | className?: string; | |
styleoptional | style?: CSSProperties; | |
classNamesoptional | classNames?: Partial<Record<DataGridPart, string>>; | |
stylesoptional | styles?: Partial<Record<DataGridPart, CSSProperties>>; | |
iconsoptional | icons?: DataGridIcons | undefined; | Icon overrides by name:
a node replaces the built-in SVG icon, |
refoptional | ref?: Ref<DataGridApi<Row>>; | Receives the grid instance; the root element is |
idoptional | id?: string; | |
aria-labeloptional | 'aria-label'?: string; | |
aria-labelledbyoptional | 'aria-labelledby'?: string; | |
aria-describedbyoptional | 'aria-describedby'?: string; | |
onWarningoptional | onWarning?: (warning: DataGridWarning) => void; | |
onReadyoptional | onReady?: (api: DataGridApi<Row>) => void; | Fires once after the first commit with the instance. |
selectionoptional | selection?: boolean | DataGridSelection; | Selection. On by default: single row selection. |
onBeforeSelectionChangeoptional | onBeforeSelectionChange?: (event: DataGridSelectionChangeEvent<Row>) => void; | Cancel with |
onSelectionChangeoptional | onSelectionChange?: (event: DataGridSelectionChangeEvent<Row>) => void; | |
keyBindingsoptional | keyBindings?: Readonly<Record<string, readonly string[]>>; | Replaces the combos of keyboard commands ( |
onKeyDownoptional | onKeyDown?: (ctx: DataGridKeyDownContext) => void; | Called for every key pressed in the grid before the built-in binding runs. |
localeTextoptional | localeText?: DataGridLocaleText; | Text overrides over the English catalog ( |
persistStateoptional | persistState?: boolean | DataGridPersistState; | Saves the user's grid state (column order, widths, visibility, pinning,
sorting, filters, grouping, page, search, selection, scroll) and restores
it on mount. |
pinnedColumnsoptionalinherited | pinnedColumns?: DataGridPinnedColumns; | The first / last N visible columns are pinned. Reactive. |
stickyRowsoptionalinherited | stickyRows?: number; | The first N rows of the visible row model stick below the header. |
stickyBottomRowsoptionalinherited | stickyBottomRows?: number; | The last N rows of the visible row model stick above the footer. |
onBeforeColumnPinChangeoptionalinherited | onBeforeColumnPinChange?: ((event: DataGridColumnPinChangeEvent) => void); | |
onColumnPinChangeoptionalinherited | onColumnPinChange?: ((event: DataGridColumnPinChangeEvent) => void); | |
mergeCellsoptionalinherited | mergeCells?: DataGridMergeCells; | DataGrid-wide merging of equal adjacent values (row merging also works under row virtualization). |
columnMenuoptionalinherited | columnMenu?: boolean | readonly (DataGridMenuItem | DataGridColumnMenuItemId)[]; | Column menu; an array lists the items in order (built-in ids or custom items). |
onBeforeColumnMenuOpenoptionalinherited | onBeforeColumnMenuOpen?: ((event: DataGridColumnMenuOpenEvent<Row>) => void); | |
onBeforeColumnMenuCloseoptionalinherited | onBeforeColumnMenuClose?: ((event: DataGridColumnMenuCloseEvent<Row>) => void); | |
onColumnMenuItemClickoptionalinherited | onColumnMenuItemClick?: ((event: DataGridColumnMenuItemClickEvent<Row>) => void); | |
renderColumnMenuoptionalinherited | renderColumnMenu?: ((ctx: DataGridColumnMenuContext<Row>) => ReactNode); | |
columnChooseroptionalinherited | columnChooser?: boolean | DataGridColumnChooser<Row>; | |
onBeforeColumnChooserOpenoptionalinherited | onBeforeColumnChooserOpen?: ((event: DataGridColumnChooserOpenEvent<Row>) => void); | |
toolbaroptionalinherited | toolbar?: readonly (DataGridToolbarItem | DataGridToolbarItemId)[]; | |
onToolbarItemClickoptionalinherited | onToolbarItemClick?: ((event: DataGridToolbarItemClickEvent) => void); | |
renderToolbaroptionalinherited | renderToolbar?: ((ctx: DataGridToolbarContext<Row>) => ReactNode); | |
contextMenuoptionalinherited | contextMenu?: boolean | readonly (DataGridMenuItem | DataGridContextMenuItemId)[]; | Context menu; an array lists the items in order. Items that do not apply to the target are dropped. |
onBeforeContextMenuOpenoptionalinherited | onBeforeContextMenuOpen?: ((event: DataGridContextMenuOpenEvent) => void); | |
onBeforeContextMenuCloseoptionalinherited | onBeforeContextMenuClose?: ((event: DataGridContextMenuCloseEvent) => void); | |
onContextMenuItemClickoptionalinherited | onContextMenuItemClick?: ((event: DataGridContextMenuItemClickEvent<Row>) => void); | |
renderContextMenuoptionalinherited | renderContextMenu?: ((ctx: DataGridContextMenuContext) => ReactNode); | |
onColumnResizeStartoptionalinherited | onColumnResizeStart?: ((event: DataGridColumnResizeEvent) => void); | |
onColumnResizeoptionalinherited | onColumnResize?: ((event: DataGridColumnResizeEvent) => void); | |
onColumnResizeEndoptionalinherited | onColumnResizeEnd?: ((event: DataGridColumnResizeEvent) => void); | |
onColumnDragStartoptionalinherited | onColumnDragStart?: ((event: DataGridColumnDragEvent) => void); | |
onColumnDragoptionalinherited | onColumnDrag?: ((event: DataGridColumnDragEvent) => void); | |
onColumnDropoptionalinherited | onColumnDrop?: ((event: DataGridColumnDragEvent) => void); | |
adaptiveoptionalinherited | adaptive?: boolean | DataGridAdaptive; | Adaptive UI ( |
onBeforeAdaptiveDialogOpenoptionalinherited | onBeforeAdaptiveDialogOpen?: ((event: DataGridAdaptiveDialogOpenEvent) => void); | |
onBeforeCopyoptionalinherited | onBeforeCopy?: ((event: DataGridBeforeCopyEvent) => void); | |
onBeforePasteoptionalinherited | onBeforePaste?: ((event: DataGridBeforePasteEvent) => void); | |
onBeforeFilloptionalinherited | onBeforeFill?: ((event: DataGridBeforeFillEvent) => void); | |
editingoptionalinherited | editing?: boolean | DataGridEditing<Row>; | Editing. |
onBeforeEditStartoptionalinherited | onBeforeEditStart?: ((event: DataGridEditStartEvent<Row>) => void); | |
onEditStartoptionalinherited | onEditStart?: ((event: DataGridEditStartEvent<Row>) => void); | |
onBeforeCellValueChangeoptionalinherited | onBeforeCellValueChange?: ((event: DataGridCellValueChangeEvent) => void); | |
onCellValueChangeoptionalinherited | onCellValueChange?: ((event: DataGridCellValueChangeEvent) => void); | |
onBeforeSaveoptionalinherited | onBeforeSave?: ((event: DataGridSaveEvent<Row>) => void); | |
onSaveoptionalinherited | onSave?: ((event: DataGridSaveEvent<Row>) => void); | |
onBeforeAddoptionalinherited | onBeforeAdd?: ((event: DataGridAddEvent<Row>) => void); | |
onAddoptionalinherited | onAdd?: ((event: DataGridAddEvent<Row>) => void); | |
onBeforeDeleteoptionalinherited | onBeforeDelete?: ((event: DataGridDeleteEvent<Row>) => void); | |
onDeleteoptionalinherited | onDelete?: ((event: DataGridDeleteEvent<Row>) => void); | |
onBeforeEditCanceloptionalinherited | onBeforeEditCancel?: ((event: DataGridEditCancelEvent) => void); | |
onEditCanceloptionalinherited | onEditCancel?: ((event: DataGridEditCancelEvent) => void); | |
onCommandClickoptionalinherited | onCommandClick?: ((event: DataGridCommandClickEvent<Row>) => void); | |
sortingoptionalinherited | sorting?: boolean | DataGridSorting; |
|
filteringoptionalinherited | filtering?: boolean | DataGridFiltering; |
|
searchoptionalinherited | search?: boolean | DataGridSearch; |
|
pagingoptionalinherited | paging?: boolean | DataGridPaging; |
|
renderPageroptionalinherited | renderPager?: ((ctx: DataGridPagerContext) => ReactNode); | Replaces the pager. |
onBeforeSortChangeoptionalinherited | onBeforeSortChange?: ((event: DataGridSortChangeEvent) => void); | |
onSortChangeoptionalinherited | onSortChange?: ((event: DataGridSortChangeEvent) => void); | |
onBeforeFilterChangeoptionalinherited | onBeforeFilterChange?: ((event: DataGridFilterChangeEvent) => void); | |
onFilterChangeoptionalinherited | onFilterChange?: ((event: DataGridFilterChangeEvent) => void); | |
onBeforeFilterMenuOpenoptionalinherited | onBeforeFilterMenuOpen?: ((event: DataGridFilterMenuOpenEvent) => void); | |
onFilterMenuOpenoptionalinherited | onFilterMenuOpen?: ((event: DataGridFilterMenuOpenEvent) => void); | |
onBeforeSearchChangeoptionalinherited | onBeforeSearchChange?: ((event: DataGridSearchChangeEvent) => void); | |
onSearchChangeoptionalinherited | onSearchChange?: ((event: DataGridSearchChangeEvent) => void); | |
onBeforePageChangeoptionalinherited | onBeforePageChange?: ((event: DataGridPageChangeEvent) => void); | |
onPageChangeoptionalinherited | onPageChange?: ((event: DataGridPageChangeEvent) => void); | |
onErroroptionalinherited | onError?: ((event: DataGridErrorEvent) => void); | An action was rejected (unknown column, page out of range, ...). |
renderDetailoptionalinherited | renderDetail?: ((ctx: DataGridDetailContext<Row>) => ReactNode); | Detail row content below each expanded row. |
detailHeightoptionalinherited | detailHeight?: number; | Estimated detail row height in px before measurement. Default 150. |
hasDetailoptionalinherited | hasDetail?: ((row: Row) => boolean); | Rows without a detail (no toggle). Called for rendered rows only. |
loadDetailoptionalinherited | loadDetail?: ((ctx: DataGridDetailLoadContext<Row>) => unknown); | Async detail content, started on expand; |
defaultExpandedDetailsoptionalinherited | defaultExpandedDetails?: boolean | readonly string[]; | Initially expanded details: |
childGridoptionalinherited | childGrid?: DataGridChildGrid<unknown, Row>; | Child grid inside each expanded row (hierarchy grid). An inline object
sees child rows as |
onBeforeDetailToggleoptionalinherited | onBeforeDetailToggle?: ((event: DataGridDetailToggleEvent<Row>) => void); | |
onDetailToggleoptionalinherited | onDetailToggle?: ((event: DataGridDetailToggleEvent<Row>) => void); | |
rowDragoptionalinherited | rowDrag?: boolean | DataGridRowDrag; | Row drag and drop with a drag handle column; |
onRowDragStartoptionalinherited | onRowDragStart?: ((event: DataGridRowDragEvent<Row>) => void); | Cancel with |
onRowDragoptionalinherited | onRowDrag?: ((event: DataGridRowDragEvent<Row>) => void); | Once per animation frame while dragging. |
onBeforeRowDropoptionalinherited | onBeforeRowDrop?: ((event: DataGridRowDragEvent<Row>) => void); | Cancel with |
onRowDropoptionalinherited | onRowDrop?: ((event: DataGridRowDragEvent<Row>) => void); | |
renderRowDragPreviewoptionalinherited | renderRowDragPreview?: ((ctx: DataGridRowDragPreviewContext<Row>) => ReactNode); | Drag preview content (default: the first cell text and the row count). |
exportWritersoptionalinherited | exportWriters?: DataGridExportWriters; | Excel and PDF writer loaders; without one the matching toolbar and menu items are disabled. |
onBeforeExportoptionalinherited | onBeforeExport?: ((event: DataGridBeforeExportEvent<Row>) => void); | |
onExportoptionalinherited | onExport?: ((event: DataGridExportEvent<Row>) => void); | |
printingoptionalinherited | printing?: DataGridPrinting<Row>; | Print scope and hierarchy mode ( |
onBeforePrintoptionalinherited | onBeforePrint?: ((event: DataGridBeforePrintEvent) => void); | |
onAfterPrintoptionalinherited | onAfterPrint?: ((event: DataGridAfterPrintEvent) => void); | |
loadingIndicatoroptionalinherited | loadingIndicator?: "skeleton" | "spinner"; | Built-in loading indicator. Default |
renderLoadingoptionalinherited | renderLoading?: ((ctx: DataGridLoadingContext) => ReactNode); | Replaces the content of the loading indicator (presentational: the grid announces loading itself). |
onRowClickoptionalinherited | onRowClick?: ((event: DataGridRowClickEvent<Row>) => void); | A data row was clicked. |
onRowDoubleClickoptionalinherited | onRowDoubleClick?: ((event: DataGridRowClickEvent<Row>) => void); | A data row was double-clicked. |
onCellClickoptionalinherited | onCellClick?: ((event: DataGridCellClickEvent<Row>) => void); | A cell of a data row was clicked; fires before |
onCellDoubleClickoptionalinherited | onCellDoubleClick?: ((event: DataGridCellClickEvent<Row>) => void); | A cell of a data row was double-clicked; fires before |
recordCommandsoptionalinherited | recordCommands?: boolean; | Keeps a serializable log of applied commands ( |
instrumentoptionalinherited | instrument?: boolean; | Exposes store counters ( |
treeoptionalinherited | tree?: boolean | DataGridTree<Row>; | Tree mode: rows with children, indented in the tree column. Read at creation (its options are reactive). |
onBeforeTreeToggleoptionalinherited | onBeforeTreeToggle?: ((event: DataGridTreeToggleEvent<Row>) => void); | |
onTreeToggleoptionalinherited | onTreeToggle?: ((event: DataGridTreeToggleEvent<Row>) => void); | |
isRowPinnedoptionalinherited | isRowPinned?: ((row: Row) => boolean); | Rows pinned to the top zone. Pinned rows stay
visible above the scrolling rows on every page, are left out of
|
defaultPinnedRowsoptionalinherited | defaultPinnedRows?: readonly string[]; | Initially pinned row ids (initial only). Turns row pinning on; pass |
onBeforeFilterBuilderOpenoptionalinherited | onBeforeFilterBuilderOpen?: ((event: DataGridFilterBuilderOpenEvent) => void); |