View as Markdown

API reference: @salmonui/data-grid

DataGridChildGridinterface

import type { DataGridChildGrid } from '@salmonui/data-grid';
interface DataGridChildGrid<Child = unknown, Parent = unknown> extends Omit<DataGridProps<Child>, 'data' | 'id' | 'ref' | 'children'> {
    readonly data: readonly Child[] | DataSource<Child> | ((parent: DataGridChildGridParent<Parent>) => readonly Child[] | DataSource<Child>);
    readonly joinField?: string;
    readonly parentField?: string;
    readonly childField?: string;
}

childGrid prop: every DataGrid prop of the child, plus the child rows and the relation. The child inherits locale, dir, timeZone, and currency unless set.

DataGridChildGrid members (163, 159 inherited)
NameSignatureDescription
datareadonly data: readonly Child[] | DataSource<Child> | ((parent: DataGridChildGridParent<Parent>) => readonly Child[] | DataSource<Child>);

Child rows: one array shared by every parent (indexed once by the join value), a data source (remote sources receive the relation filter), or a factory per parent.

joinFieldoptionalreadonly joinField?: string;

Field present in parent and child rows.

parentFieldoptionalreadonly parentField?: string;

Parent field when the names differ. Default joinField.

childFieldoptionalreadonly childField?: string;

Child field when the names differ. Default joinField.

pinnedColumnsoptionalinheritedpinnedColumns?: DataGridPinnedColumns;

The first / last N visible columns are pinned. Reactive.

stickyRowsoptionalinheritedstickyRows?: number;

The first N rows of the visible row model stick below the header.

stickyBottomRowsoptionalinheritedstickyBottomRows?: number;

The last N rows of the visible row model stick above the footer.

onBeforeColumnPinChangeoptionalinheritedonBeforeColumnPinChange?: ((event: DataGridColumnPinChangeEvent) => void);
onColumnPinChangeoptionalinheritedonColumnPinChange?: ((event: DataGridColumnPinChangeEvent) => void);
mergeCellsoptionalinheritedmergeCells?: DataGridMergeCells;

DataGrid-wide merging of equal adjacent values (row merging also works under row virtualization).

columnMenuoptionalinheritedcolumnMenu?: boolean | readonly (DataGridMenuItem | DataGridColumnMenuItemId)[];

Column menu; an array lists the items in order (built-in ids or custom items). column.menu: false opts a column out.

onBeforeColumnMenuOpenoptionalinheritedonBeforeColumnMenuOpen?: ((event: DataGridColumnMenuOpenEvent<Child>) => void);
onBeforeColumnMenuCloseoptionalinheritedonBeforeColumnMenuClose?: ((event: DataGridColumnMenuCloseEvent<Child>) => void);
onColumnMenuItemClickoptionalinheritedonColumnMenuItemClick?: ((event: DataGridColumnMenuItemClickEvent<Child>) => void);
renderColumnMenuoptionalinheritedrenderColumnMenu?: ((ctx: DataGridColumnMenuContext<Child>) => ReactNode);
columnChooseroptionalinheritedcolumnChooser?: boolean | DataGridColumnChooser<Child>;
onBeforeColumnChooserOpenoptionalinheritedonBeforeColumnChooserOpen?: ((event: DataGridColumnChooserOpenEvent<Child>) => void);
toolbaroptionalinheritedtoolbar?: readonly (DataGridToolbarItem | DataGridToolbarItemId)[];
onToolbarItemClickoptionalinheritedonToolbarItemClick?: ((event: DataGridToolbarItemClickEvent) => void);
renderToolbaroptionalinheritedrenderToolbar?: ((ctx: DataGridToolbarContext<Child>) => ReactNode);
contextMenuoptionalinheritedcontextMenu?: boolean | readonly (DataGridMenuItem | DataGridContextMenuItemId)[];

Context menu; an array lists the items in order. Items that do not apply to the target are dropped.

onBeforeContextMenuOpenoptionalinheritedonBeforeContextMenuOpen?: ((event: DataGridContextMenuOpenEvent) => void);
onBeforeContextMenuCloseoptionalinheritedonBeforeContextMenuClose?: ((event: DataGridContextMenuCloseEvent) => void);
onContextMenuItemClickoptionalinheritedonContextMenuItemClick?: ((event: DataGridContextMenuItemClickEvent<Child>) => void);
renderContextMenuoptionalinheritedrenderContextMenu?: ((ctx: DataGridContextMenuContext) => ReactNode);
onColumnResizeStartoptionalinheritedonColumnResizeStart?: ((event: DataGridColumnResizeEvent) => void);
onColumnResizeoptionalinheritedonColumnResize?: ((event: DataGridColumnResizeEvent) => void);
onColumnResizeEndoptionalinheritedonColumnResizeEnd?: ((event: DataGridColumnResizeEvent) => void);
onColumnDragStartoptionalinheritedonColumnDragStart?: ((event: DataGridColumnDragEvent) => void);
onColumnDragoptionalinheritedonColumnDrag?: ((event: DataGridColumnDragEvent) => void);
onColumnDropoptionalinheritedonColumnDrop?: ((event: DataGridColumnDragEvent) => void);
adaptiveoptionalinheritedadaptive?: boolean | DataGridAdaptive;

Adaptive UI (enableAdaptiveUI, adaptiveUIMode, rowRenderingMode): full-screen sheets for menus and dialogs, 44 px touch targets, touch long-press, and optional vertical (card) rows. true is { target: 'both' }.

onBeforeAdaptiveDialogOpenoptionalinheritedonBeforeAdaptiveDialogOpen?: ((event: DataGridAdaptiveDialogOpenEvent) => void);
onBeforeCopyoptionalinheritedonBeforeCopy?: ((event: DataGridBeforeCopyEvent) => void);
onBeforePasteoptionalinheritedonBeforePaste?: ((event: DataGridBeforePasteEvent) => void);
onBeforeFilloptionalinheritedonBeforeFill?: ((event: DataGridBeforeFillEvent) => void);
editingoptionalinheritedediting?: boolean | DataGridEditing<Child>;

Editing. true for the defaults (row mode). The module is registered when the initial value is set.

onBeforeEditStartoptionalinheritedonBeforeEditStart?: ((event: DataGridEditStartEvent<Child>) => void);
onEditStartoptionalinheritedonEditStart?: ((event: DataGridEditStartEvent<Child>) => void);
onBeforeCellValueChangeoptionalinheritedonBeforeCellValueChange?: ((event: DataGridCellValueChangeEvent) => void);
onCellValueChangeoptionalinheritedonCellValueChange?: ((event: DataGridCellValueChangeEvent) => void);
onBeforeSaveoptionalinheritedonBeforeSave?: ((event: DataGridSaveEvent<Child>) => void);
onSaveoptionalinheritedonSave?: ((event: DataGridSaveEvent<Child>) => void);
onBeforeAddoptionalinheritedonBeforeAdd?: ((event: DataGridAddEvent<Child>) => void);
onAddoptionalinheritedonAdd?: ((event: DataGridAddEvent<Child>) => void);
onBeforeDeleteoptionalinheritedonBeforeDelete?: ((event: DataGridDeleteEvent<Child>) => void);
onDeleteoptionalinheritedonDelete?: ((event: DataGridDeleteEvent<Child>) => void);
onBeforeEditCanceloptionalinheritedonBeforeEditCancel?: ((event: DataGridEditCancelEvent) => void);
onEditCanceloptionalinheritedonEditCancel?: ((event: DataGridEditCancelEvent) => void);
onCommandClickoptionalinheritedonCommandClick?: ((event: DataGridCommandClickEvent<Child>) => void);
sortingoptionalinheritedsorting?: boolean | DataGridSorting;

true or options: header sorting.

filteringoptionalinheritedfiltering?: boolean | DataGridFiltering;

true or options: filtering and its UI.

searchoptionalinheritedsearch?: boolean | DataGridSearch;

true or options: searching.

pagingoptionalinheritedpaging?: boolean | DataGridPaging;

true or options: paging and the pager.

renderPageroptionalinheritedrenderPager?: ((ctx: DataGridPagerContext) => ReactNode);

Replaces the pager.

onBeforeSortChangeoptionalinheritedonBeforeSortChange?: ((event: DataGridSortChangeEvent) => void);
onSortChangeoptionalinheritedonSortChange?: ((event: DataGridSortChangeEvent) => void);
onBeforeFilterChangeoptionalinheritedonBeforeFilterChange?: ((event: DataGridFilterChangeEvent) => void);
onFilterChangeoptionalinheritedonFilterChange?: ((event: DataGridFilterChangeEvent) => void);
onBeforeFilterMenuOpenoptionalinheritedonBeforeFilterMenuOpen?: ((event: DataGridFilterMenuOpenEvent) => void);
onFilterMenuOpenoptionalinheritedonFilterMenuOpen?: ((event: DataGridFilterMenuOpenEvent) => void);
onBeforeSearchChangeoptionalinheritedonBeforeSearchChange?: ((event: DataGridSearchChangeEvent) => void);
onSearchChangeoptionalinheritedonSearchChange?: ((event: DataGridSearchChangeEvent) => void);
onBeforePageChangeoptionalinheritedonBeforePageChange?: ((event: DataGridPageChangeEvent) => void);
onPageChangeoptionalinheritedonPageChange?: ((event: DataGridPageChangeEvent) => void);
onErroroptionalinheritedonError?: ((event: DataGridErrorEvent) => void);

An action was rejected (unknown column, page out of range, ...).

renderDetailoptionalinheritedrenderDetail?: ((ctx: DataGridDetailContext<Child>) => ReactNode);

Detail row content below each expanded row.

detailHeightoptionalinheriteddetailHeight?: number;

Estimated detail row height in px before measurement. Default 150.

hasDetailoptionalinheritedhasDetail?: ((row: Child) => boolean);

Rows without a detail (no toggle). Called for rendered rows only.

loadDetailoptionalinheritedloadDetail?: ((ctx: DataGridDetailLoadContext<Child>) => unknown);

Async detail content, started on expand; renderDetail receives status, data, error.

defaultExpandedDetailsoptionalinheriteddefaultExpandedDetails?: boolean | readonly string[];

Initially expanded details: true for every row, or row ids (initial only).

childGridoptionalinheritedchildGrid?: DataGridChildGrid<unknown, Child>;

Child grid inside each expanded row (hierarchy grid). An inline object sees child rows as unknown; defineChildGrid<Child, Parent>(config) types the child rows.

onBeforeDetailToggleoptionalinheritedonBeforeDetailToggle?: ((event: DataGridDetailToggleEvent<Child>) => void);
onDetailToggleoptionalinheritedonDetailToggle?: ((event: DataGridDetailToggleEvent<Child>) => void);
rowDragoptionalinheritedrowDrag?: boolean | DataGridRowDrag;

Row drag and drop with a drag handle column; true reorders within the grid.

onRowDragStartoptionalinheritedonRowDragStart?: ((event: DataGridRowDragEvent<Child>) => void);

Cancel with event.preventDefault().

onRowDragoptionalinheritedonRowDrag?: ((event: DataGridRowDragEvent<Child>) => void);

Once per animation frame while dragging.

onBeforeRowDropoptionalinheritedonBeforeRowDrop?: ((event: DataGridRowDragEvent<Child>) => void);

Cancel with event.preventDefault().

onRowDropoptionalinheritedonRowDrop?: ((event: DataGridRowDragEvent<Child>) => void);
renderRowDragPreviewoptionalinheritedrenderRowDragPreview?: ((ctx: DataGridRowDragPreviewContext<Child>) => ReactNode);

Drag preview content (default: the first cell text and the row count).

exportWritersoptionalinheritedexportWriters?: DataGridExportWriters;

Excel and PDF writer loaders; without one the matching toolbar and menu items are disabled.

onBeforeExportoptionalinheritedonBeforeExport?: ((event: DataGridBeforeExportEvent<Child>) => void);
onExportoptionalinheritedonExport?: ((event: DataGridExportEvent<Child>) => void);
printingoptionalinheritedprinting?: DataGridPrinting<Child>;

Print scope and hierarchy mode (print() options override them).

onBeforePrintoptionalinheritedonBeforePrint?: ((event: DataGridBeforePrintEvent) => void);
onAfterPrintoptionalinheritedonAfterPrint?: ((event: DataGridAfterPrintEvent) => void);
loadingIndicatoroptionalinheritedloadingIndicator?: "skeleton" | "spinner";

Built-in loading indicator. Default spinner.

renderLoadingoptionalinheritedrenderLoading?: ((ctx: DataGridLoadingContext) => ReactNode);

Replaces the content of the loading indicator (presentational: the grid announces loading itself).

onRowClickoptionalinheritedonRowClick?: ((event: DataGridRowClickEvent<Child>) => void);

A data row was clicked. preventDefault() skips the built-in selection and focus.

onRowDoubleClickoptionalinheritedonRowDoubleClick?: ((event: DataGridRowClickEvent<Child>) => void);

A data row was double-clicked. preventDefault() skips the built-in edit start.

onCellClickoptionalinheritedonCellClick?: ((event: DataGridCellClickEvent<Child>) => void);

A cell of a data row was clicked; fires before onRowClick.

onCellDoubleClickoptionalinheritedonCellDoubleClick?: ((event: DataGridCellClickEvent<Child>) => void);

A cell of a data row was double-clicked; fires before onRowDoubleClick.

recordCommandsoptionalinheritedrecordCommands?: boolean;

Keeps a serializable log of applied commands (api.engine.getCommandLog()). Initial only. Default false.

instrumentoptionalinheritedinstrument?: boolean;

Exposes store counters (api.engine.getInstrumentation()). Initial only. Default false.

treeoptionalinheritedtree?: boolean | DataGridTree<Child>;

Tree mode: rows with children, indented in the tree column. Read at creation (its options are reactive).

onBeforeTreeToggleoptionalinheritedonBeforeTreeToggle?: ((event: DataGridTreeToggleEvent<Child>) => void);
onTreeToggleoptionalinheritedonTreeToggle?: ((event: DataGridTreeToggleEvent<Child>) => void);
isRowPinnedoptionalinheritedisRowPinned?: ((row: Child) => boolean);

Rows pinned to the top zone. Pinned rows stay visible above the scrolling rows on every page, are left out of pageSize, and follow sorting, filtering, search and edits. Pure; read once when the grid is created. Turns row pinning on.

defaultPinnedRowsoptionalinheriteddefaultPinnedRows?: readonly string[];

Initially pinned row ids (initial only). Turns row pinning on; pass [] to only use pinRows.

onBeforeFilterBuilderOpenoptionalinheritedonBeforeFilterBuilderOpen?: ((event: DataGridFilterBuilderOpenEvent) => void);
columnsoptionalinheritedcolumns?: readonly DataGridColumn<Child>[];

Column definitions; <DataGridColumn> children are the JSX form (children win over columns).

getRowIdoptionalinheritedgetRowId?: ((row: Child) => string | number);

Row identity. Default: the primaryKey column(s), else the id field (with a development warning).

modulesoptionalinheritedmodules?: readonly DataGridModule<Child, unknown, DataGridCommand, string, {}>[];

Extra core modules (initial only).

featuresoptionalinheritedfeatures?: readonly DataGridFeature[];

Salmon. Render features to use synchronously, from @salmonui/data-grid/features. Optional: a grid loads the features its props need on demand; features passed here skip that load (no placeholder on a client-only render). Read at creation.

localeoptionalinheritedlocale?: string;
timeZoneoptionalinheritedtimeZone?: string;

IANA time zone for date formatting. Set it for SSR: server and client must format identically.

currencyoptionalinheritedcurrency?: string;
diroptionalinheriteddir?: "auto" | "ltr" | "rtl";

Text direction. 'auto' follows the locale script (ar, he, fa, ... are right-to-left). Default: the inherited dir. Reactive.

heightoptionalinheritedheight?: string | number;

Viewport height: px, any CSS length ('100%' needs a fixed-height parent), or 'auto' (no row virtualization). Default 400.

widthoptionalinheritedwidth?: string | number;
rowHeightoptionalinheritedrowHeight?: number;

Fixed row height in px. Default 36.

getRowHeightoptionalinheritedgetRowHeight?: ((row: Child) => number);

Per-row fixed height.

estimatedRowHeightoptionalinheritedestimatedRowHeight?: number;

Enables measured row heights with this estimate (variable content, templates, wrapping).

headerHeightoptionalinheritedheaderHeight?: number;

Header row height in px (per stacked level). Default 40.

defaultColumnWidthoptionalinheriteddefaultColumnWidth?: number;

Width of columns without width. Default 160.

virtualizationoptionalinheritedvirtualization?: boolean | DataGridVirtualization;

Row and column virtualization; true (default) for the defaults, false renders every row and column.

infiniteScrolloptionalinheritedinfiniteScroll?: boolean | DataGridInfiniteScroll<Child>;

Infinite scrolling for remote sources: rows load in blocks as the viewport approaches them.

renderLoadingRowoptionalinheritedrenderLoadingRow?: ((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.

initialRowsoptionalinheritedinitialRows?: number;

Rows in the deterministic server/initial range. Default 20.

initialColumnsoptionalinheritedinitialColumns?: number;

Center columns in the deterministic server/initial range. Default 20.

textWrapoptionalinheritedtextWrap?: DataGridTextWrap;
gridLinesoptionalinheritedgridLines?: DataGridLines;
overflowoptionalinheritedoverflow?: DataGridOverflow;

Default text overflow of every column. Default ellipsis.

highlightOnHoveroptionalinheritedhighlightOnHover?: boolean;

Row hover highlight. Default true.

stripedoptionalinheritedstriped?: boolean;

Alternate row shading. Default true.

resizableoptionalinheritedresizable?: boolean;

Pointer and keyboard column resize. Default false; column resizable refines it.

resizeModeoptionalinheritedresizeMode?: "auto" | "normal";

Column fit. 'normal' (default): widths are kept, leaving empty space or scrolling. 'auto': when the columns are narrower than the grid they stretch proportionally to fill it, and a pointer resize re-fits the other columns.

reorderableoptionalinheritedreorderable?: boolean;

Pointer and keyboard column reorder. Default false; column reorderable refines it.

onBeforeColumnVisibilityChangeoptionalinheritedonBeforeColumnVisibilityChange?: ((event: DataGridColumnVisibilityChangeEvent) => void);
onColumnVisibilityChangeoptionalinheritedonColumnVisibilityChange?: ((event: DataGridColumnVisibilityChangeEvent) => void);
onBeforeColumnReorderoptionalinheritedonBeforeColumnReorder?: ((event: DataGridColumnReorderEvent) => void);
onColumnReorderoptionalinheritedonColumnReorder?: ((event: DataGridColumnReorderEvent) => void);
groupingoptionalinheritedgrouping?: boolean | DataGridGrouping<Child>;

true or settings: grouping UI and behavior.

onBeforeGroupChangeoptionalinheritedonBeforeGroupChange?: ((event: DataGridGroupChangeEvent) => void);
onGroupChangeoptionalinheritedonGroupChange?: ((event: DataGridGroupChangeEvent) => void);
onBeforeGroupToggleoptionalinheritedonBeforeGroupToggle?: ((event: DataGridGroupToggleEvent<Child>) => void);
onGroupToggleoptionalinheritedonGroupToggle?: ((event: DataGridGroupToggleEvent<Child>) => void);
aggregatesoptionalinheritedaggregates?: readonly DataGridAggregateRow<Child>[];

Aggregate rows (or <DataGridAggregateRow> children).

aggregateScopeoptionalinheritedaggregateScope?: "all" | "page";

With paging: page (default) aggregates the current page, all every matching row.

renderRowoptionalinheritedrenderRow?: ((ctx: DataGridRowContext<Child>) => ReactNode);
renderEmptyoptionalinheritedrenderEmpty?: ((ctx: DataGridEmptyContext) => ReactNode);
renderErroroptionalinheritedrenderError?: ((ctx: DataGridDataErrorContext) => ReactNode);

Body content while the data source failed to load. Default: the error message and a Retry button.

onViewChangeoptionalinheritedonViewChange?: ((event: DataGridViewChangeEvent) => void);

Once per committed change of the displayed rows; never on scroll, focus, selection, or expansion.

getRowPropsoptionalinheritedgetRowProps?: ((row: Child, rowIndex: number, ctx: { readonly tree?: DataGridTreeContext; }) => DataGridElementProps | undefined);

Called for rendered rows only; ctx.tree in tree mode.

rowClassNameoptionalinheritedrowClassName?: ((row: Child, rowIndex: number) => string | undefined);
getCellPropsoptionalinheritedgetCellProps?: ((ctx: DataGridCellContext<Child>) => DataGridElementProps | undefined);

Called for rendered cells only.

classNameoptionalinheritedclassName?: string;
styleoptionalinheritedstyle?: CSSProperties;
classNamesoptionalinheritedclassNames?: Partial<Record<DataGridPart, string>>;
stylesoptionalinheritedstyles?: Partial<Record<DataGridPart, CSSProperties>>;
iconsoptionalinheritedicons?: Partial<Record<DataGridIconName, ReactNode>>;

Icon overrides by name: a node replaces the built-in SVG icon, null hides it. Merges over an enclosing DataGridIconsProvider. A component prop, not a theme input.

aria-labeloptionalinheritedaria-label?: string;
aria-labelledbyoptionalinheritedaria-labelledby?: string;
aria-describedbyoptionalinheritedaria-describedby?: string;
onWarningoptionalinheritedonWarning?: ((warning: DataGridWarning) => void);
onReadyoptionalinheritedonReady?: ((api: DataGridApi<Child>) => void);

Fires once after the first commit with the instance.

selectionoptionalinheritedselection?: boolean | DataGridSelection;

Selection. On by default: single row selection. false turns it off.

onBeforeSelectionChangeoptionalinheritedonBeforeSelectionChange?: ((event: DataGridSelectionChangeEvent<Child>) => void);

Cancel with event.preventDefault().

onSelectionChangeoptionalinheritedonSelectionChange?: ((event: DataGridSelectionChangeEvent<Child>) => void);
keyBindingsoptionalinheritedkeyBindings?: Readonly<Record<string, readonly string[]>>;

Replaces the combos of keyboard commands ({ 'selection.selectAll': ['Mod+Shift+L'] }). Reactive: a changed value (compared by value) rebuilds the keymap.

onKeyDownoptionalinheritedonKeyDown?: ((ctx: DataGridKeyDownContext) => void);

Called for every key pressed in the grid before the built-in binding runs.

localeTextoptionalinheritedlocaleText?: DataGridLocaleText;

Text overrides over the English catalog (DATA_GRID_DEFAULT_LOCALE_TEXT): every visible and assistive string of the grid. Plain JSON with {param} templates and plural forms. Reactive.

persistStateoptionalinheritedpersistState?: 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. true uses localStorage under salmon-data-grid:<id> (set id); an object sets the key, storage, excluded parts, and an application version. Read on mount.