View as Markdown

API reference: @salmonui/data-grid

DataGridTreeinterface

import type { DataGridTree } from '@salmonui/data-grid';
interface DataGridTree<Row = unknown> {
    readonly childrenField?: string;
    readonly parentIdField?: string;
    readonly hasChildrenField?: string;
    readonly expandedField?: string;
    readonly column?: string;
    readonly defaultExpanded?: boolean | number;
    readonly expandedRows?: Readonly<Record<RowId, boolean>>;
    readonly filterMode?: DataGridTreeFilterMode;
    readonly pageBy?: 'all' | 'root';
    readonly checkbox?: boolean | {
        readonly cascade?: boolean | 'filtered';
    };
    readonly copyMode?: DataGridTreeFilterMode;
    readonly loadChildren?: (ctx: DataGridTreeLoadContext<Row>) => readonly Row[] | Promise<readonly Row[]>;
}

tree prop (true: { childrenField: 'children' }).

DataGridTree members (12)
NameSignatureDescription
childrenFieldoptionalreadonly childrenField?: string;

Nested rows: the field holding child arrays. Default 'children' unless parentIdField is set.

parentIdFieldoptionalreadonly parentIdField?: string;

Flat self-referential rows: the field holding the parent's row id (parentIdMapping); the id is getRowId.

hasChildrenFieldoptionalreadonly hasChildrenField?: string;

Rows whose children load on demand (hasChildMapping).

expandedFieldoptionalreadonly expandedField?: string;

Initial expansion from a boolean data field (expandStateMapping).

columnoptionalreadonly column?: string;

Field or column id of the tree column (treeColumnIndex). Default: the first visible data column; follows reorder, pinning and hiding.

defaultExpandedoptionalreadonly defaultExpanded?: boolean | number;

true (default): parents expanded; false: collapsed (enableCollapseAll); n: depths below n expanded.

expandedRowsoptionalreadonly expandedRows?: Readonly<Record<RowId, boolean>>;

Salmon: reactive expansion overrides over defaultExpanded.

filterModeoptionalreadonly filterMode?: DataGridTreeFilterMode;

Rows a filter or search keeps (filterSettings.hierarchyMode). Default 'ancestors'.

pageByoptionalreadonly pageBy?: 'all' | 'root';

Paging counts every visible row (default) or root rows with their subtrees (pageSizeMode).

checkboxoptionalreadonly checkbox?: boolean | { readonly cascade?: boolean | 'filtered'; };

Checkbox in the tree column (column showCheckbox); its state is the row selection. cascade selects subtrees (hierarchyCheckboxMode).

copyModeoptionalreadonly copyMode?: DataGridTreeFilterMode;

Rows copy() adds around the copied rows (copyHierarchyMode). Default 'ancestors'.

loadChildrenoptionalreadonly loadChildren?: (ctx: DataGridTreeLoadContext<Row>) => readonly Row[] | Promise<readonly Row[]>;

Loads the children of a lazy row (hasChildrenField) for local data; the returned rows join the data under the row. With a remote data source the grid reads read({ parentRowId }) instead.