API reference: @salmonui/data-grid/engine/tree
TreeOptionsinterface
import type { TreeOptions } from '@salmonui/data-grid/engine/tree';interface TreeOptions<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?: TreeFilterMode;
readonly pageBy?: TreePageBy;
readonly checkbox?: boolean | {
readonly cascade?: TreeCascade;
};
readonly copyMode?: TreeFilterMode;
readonly childSummary?: boolean;
readonly loadChildren?: (ctx: TreeLoadContext<Row>) => readonly Row[] | Promise<readonly Row[]>;
readonly setParentId?: (row: Row, parentId: RowId | null) => Row;
readonly hasChildren?: (row: Row, rowId: RowId) => boolean | undefined;
readonly parentIdOf?: (row: Row, rowId: RowId) => RowId | null | undefined;
}
| Name | Signature | Description |
|---|---|---|
childrenFieldoptional | readonly childrenField?: string; | Nested rows: the field holding child arrays ( |
parentIdFieldoptional | readonly parentIdField?: string; | Flat self-referential rows: the field holding the parent's row id (root: missing, null, |
hasChildrenFieldoptional | readonly hasChildrenField?: string; | Rows whose children load on demand ( |
expandedFieldoptional | readonly expandedField?: string; | Initial expansion from a boolean data field ( |
columnoptional | readonly column?: string; | Field or column id of the tree column (default: the first visible data column; resolved by the renderer). |
defaultExpandedoptional | readonly defaultExpanded?: boolean | number; |
|
expandedRowsoptional | readonly expandedRows?: Readonly<Record<RowId, boolean>>; | Initial per-row overrides over |
filterModeoptional | readonly filterMode?: TreeFilterMode; | Rows a filter or search keeps: matches with their ancestors (default), with their descendants, both, or matches only (re-parented). |
pageByoptional | readonly pageBy?: TreePageBy; | Paging counts every visible row (default) or root rows with their subtrees. |
checkboxoptional | readonly checkbox?: boolean | {
readonly cascade?: TreeCascade;
}; | Checkbox in the tree column; |
copyModeoptional | readonly copyMode?: TreeFilterMode; | Rows |
childSummaryoptional | readonly childSummary?: boolean; | Child summary rows ( |
loadChildrenoptional | readonly loadChildren?: (ctx: TreeLoadContext<Row>) => readonly Row[] | Promise<readonly Row[]>; | Loads the children of a lazy row ( |
setParentIdoptional | readonly setParentId?: (row: Row, parentId: RowId | null) => Row; | Copy of a row with a new parent (flat data writes). Default: a shallow copy with |
hasChildrenoptional | readonly hasChildren?: (row: Row, rowId: RowId) => boolean | undefined; | Whether a row has children to load when |
parentIdOfoptional | readonly parentIdOf?: (row: Row, rowId: RowId) => RowId | null | undefined; | Parent row id of a row when the data does not carry it (remote envelopes,
tuple rows; |