View as Markdown

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;
}
TreeOptions members (16)
NameSignatureDescription
childrenFieldoptionalreadonly childrenField?: string;

Nested rows: the field holding child arrays (tree: true means 'children'). The engine source must be flattenTree(data, childrenField).

parentIdFieldoptionalreadonly parentIdField?: string;

Flat self-referential rows: the field holding the parent's row id (root: missing, null, '', or unknown).

hasChildrenFieldoptionalreadonly hasChildrenField?: string;

Rows whose children load on demand (hasChildMapping).

expandedFieldoptionalreadonly expandedField?: string;

Initial expansion from a boolean data field (expandStateMapping); overridden by expandedRows and every expand command.

columnoptionalreadonly column?: string;

Field or column id of the tree column (default: the first visible data column; resolved by the renderer).

defaultExpandedoptionalreadonly defaultExpanded?: boolean | number;

true (default): every parent expanded; false: collapsed; n: rows of depth < n expanded.

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

Initial per-row overrides over defaultExpanded (reactive input through tree.setExpanded).

filterModeoptionalreadonly filterMode?: TreeFilterMode;

Rows a filter or search keeps: matches with their ancestors (default), with their descendants, both, or matches only (re-parented).

pageByoptionalreadonly pageBy?: TreePageBy;

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

checkboxoptionalreadonly checkbox?: boolean | { readonly cascade?: TreeCascade; };

Checkbox in the tree column; cascade selects subtrees ('filtered': kept rows only).

copyModeoptionalreadonly copyMode?: TreeFilterMode;

Rows copy() adds around the copied rows (clipboard, read by the renderer).

childSummaryoptionalreadonly childSummary?: boolean;

Child summary rows (__tf:<rowId>) after the last visible descendant of each expanded parent (showChildSummary).

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

Loads the children of a lazy row (hasChildrenField). Returned rows join the data source (local sources) under the row.

setParentIdoptionalreadonly setParentId?: (row: Row, parentId: RowId | null) => Row;

Copy of a row with a new parent (flat data writes). Default: a shallow copy with parentIdField set.

hasChildrenoptionalreadonly hasChildren?: (row: Row, rowId: RowId) => boolean | undefined;

Whether a row has children to load when hasChildrenField cannot be read (remote envelopes, tuple rows; createRemoteTree). undefined falls back to hasChildrenField.

parentIdOfoptionalreadonly 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; createRemoteTree); null: a root, undefined: fall back to parentIdField (or the nesting). Setting it reads parents as flat data.