# @salmonui/data-grid/engine/tree API reference

> 65 exported symbols of @salmonui/data-grid/engine/tree: 24 functions, 1 class, 10 interfaces, 27 types and 3 constants.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-tree

```ts
import { … } from '@salmonui/data-grid/engine/tree';
```

## Functions

### applySelectionDelta

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/applySelectionDelta

```ts
function applySelectionDelta(layout: TreeLayout, counts: Int32Array, added: Iterable<number>, removed: Iterable<number>): void;
```

Applies a selection change to the counts in place: every ancestor of a changed row moves by one. O(changed × depth).

### buildTreeLayout

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/buildTreeLayout

```ts
function buildTreeLayout(parent: Int32Array, priority: Int32Array | null, keep: Uint8Array | null, base?: TreeLayout | null): TreeLayout;
```

Builds the pre-order of the rows kept by `keep` (null: every row).
`priority` lists source indexes in sibling order (the sort stage's order;
null: source order); kept rows missing from it follow in source order.
Rows whose parent is not kept hang under the nearest kept ancestor (root
when none). `base`, the source order layout of every row under `parent`
(`buildTreeLayout(parent, null, null)`), makes a re-order or an ancestor
closed filter (`filterMode` `'ancestors'` / `'both'`) skip the tree walk.
O(n).

### buildVisibleRanges

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/buildVisibleRanges

```ts
function buildVisibleRanges(layout: TreeLayout, expanded: Uint8Array, footers: boolean, allOpen?: boolean): TreeRanges;
```

Visible ranges of `layout` where `expanded[s]` (by source index) opens a
row with kept children. With `footers`, a child summary row follows the
last visible descendant of every expanded parent. O(visible rows + k);
O(1) when `allOpen` says every row is expanded (no footers).

### cascadePlan

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/cascadePlan

```ts
function cascadePlan(layout: TreeLayout, counts: Int32Array, sourceIndex: number, checked: boolean, selected: (sourceIndex: number) => boolean): {
    readonly select: number[];
    readonly deselect: number[];
};
```

Rows a cascade toggle of `sourceIndex` changes: the row and its kept
subtree (`[slot, next)`), then the ancestors whose state follows. Checking
selects every ancestor whose descendants become all selected (bottom-up,
stopping at the first that does not); unchecking deselects every selected
ancestor. Returns source indexes to select and to deselect.

### checkStateOf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/checkStateOf

```ts
function checkStateOf(layout: TreeLayout, counts: Int32Array, sourceIndex: number, own: boolean): TreeCheckState;
```

Tri-state of a row: `checked` when it and every kept descendant are
selected, `unchecked` when none is, else `mixed`.

### childrenIn

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/childrenIn

```ts
function childrenIn(layout: TreeLayout, row: number): number[];
```

Source indexes of the kept children of a row (`-1`: the roots), in sibling order.

### countSelectedDescendants

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/countSelectedDescendants

```ts
function countSelectedDescendants(layout: TreeLayout, selected: (sourceIndex: number) => boolean): Int32Array;
```

Selected descendants of every kept row of `layout` (by source index). O(n): one reverse pre-order pass.

### createTreeModule

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/createTreeModule

```ts
function createTreeModule<Row>(defaults?: TreeOptions<Row>): TreeModule<Row>;
```

Creates the `tree` module. Options come from `options` merged under
`DataGridOptions.tree` (`TreeOptions`, or `true` for nested rows under
`'children'`).

### descendantCount

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/descendantCount

```ts
function descendantCount(layout: TreeLayout, sourceIndex: number): number;
```

Kept descendants of a row.

### descendantsOf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/descendantsOf

```ts
function descendantsOf(layout: TreeLayout, row: number): Int32Array;
```

Source indexes of the kept descendants of a row, in pre-order (`[slot + 1, next)`).

### flattenTree

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/flattenTree

```ts
function flattenTree<Row>(roots: readonly Row[], childrenField: string, onIssue?: (issue: TreeIssue) => void): Row[];
```

Nested rows (`childrenField` arrays) as one flat pre-order array, rows by
reference (never copied). Iterative, so deep trees never overflow the
stack; a row that contains itself (a cycle in the nesting) is emitted once
and its looping child skipped (`onIssue` with kind `cycle`).

### getTreeState

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/getTreeState

```ts
function getTreeState<Row>(engine: DataGridEngine<Row>): TreeStatePart | null;
```

The tree part of an engine's state, or null without the tree module.

### isAncestorOf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/isAncestorOf

```ts
function isAncestorOf(layout: TreeLayout, ancestor: number, row: number): boolean;
```

True when `ancestor` is a proper ancestor of `row` in `layout` (both source indexes). O(1).

### parentsFromIds

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/parentsFromIds

```ts
function parentsFromIds(count: number, parentIdOf: (index: number) => string | null, indexOf: (id: string) => number, onIssue?: (issue: TreeIssue) => void): Int32Array;
```

Parents of flat self-referential rows. `parentIdOf(i)` returns row `i`'s
parent id (null for a root); `indexOf` resolves an id to a source index
(-1 when unknown, through the engine id index). Unknown ids make the row an
orphan root; a parent chain that loops is broken at the first repeated row,
which becomes a root.

### parentsFromNested

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/parentsFromNested

```ts
function parentsFromNested(rows: readonly unknown[], childrenField: string, indexOfRow?: (row: unknown) => number): Int32Array;
```

Parents of nested rows that are already in flat pre-order (`flattenTree`
output). One parallel walk of the nesting and the flat array; when the
flat array is not exactly the flattening (rows appended by a patch, or
reordered), falls back to an identity map, O(n) either way. A child object
that is not in `rows` (a parent replaced with copies of its children) is
matched through `indexOfRow` (the row id) when given. Rows that are
nobody's child are roots.

### positionOfSlot

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/positionOfSlot

```ts
function positionOfSlot(ranges: TreeRanges, slot: number): number;
```

Visible data position of a slot, or -1 when it is hidden by a collapsed ancestor.

### restoreTreeState

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/restoreTreeState

```ts
function restoreTreeState<Row>(engine: DataGridEngine<Row>, part: TreeStatePart): {
    readonly type: string;
    readonly reason: string;
} | null;
```

Restores a tree part (`tree.setExpanded`); null without the tree module.

### siblingInfo

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/siblingInfo

```ts
function siblingInfo(layout: TreeLayout, s: number): readonly [
    number,
    number,
    number
];
```

`[childCount, posinset, setsize]` of a kept row (source index): short
sibling walks, falling back to the layout's arrays (built on first read)
for wide sibling lists, so per-row reads stay O(1) amortized without an
O(n) pass per layout.

### slotAtPosition

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/slotAtPosition

```ts
function slotAtPosition(ranges: TreeRanges, p: number): number;
```

Slot of visible data position `p`.

### treeCopyRowIds

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/treeCopyRowIds

```ts
function treeCopyRowIds(structure: TreeStructure, rowIds: readonly RowId[], mode: 'ancestors' | 'descendants' | 'both' | 'none'): RowId[];
```

The copied row ids widened by `mode` over the kept layout of the current
query: `ancestors` adds every kept ancestor, `descendants` every kept
descendant, `both` both, `none` nothing. The result is in tree pre-order
without duplicates; ids that are not in the layout keep their relative
order after the tree rows. O(n) over the kept rows.

### treeOf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/treeOf

```ts
function treeOf<Row>(model: RowModelSnapshot<Row>): TreeStructure | null;
```

The tree (full index and kept layout) of a tree-mode model, or null.

### treePartOf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/treePartOf

```ts
function treePartOf(raw: unknown): TreeStatePart | null;
```

The `tree` part of a raw state, validated, or null.

### withTreePersistence

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/withTreePersistence

```ts
function withTreePersistence(fns: DataGridPersistenceFns): DataGridPersistenceFns;
```

Storage binding functions that include `tree.expandedRows` (wraps `DATA_GRID_PERSISTENCE_FNS`).

### withTreeState

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/withTreeState

```ts
function withTreeState<Row>(api: DataGridStateApi, engine: DataGridEngine<Row>): DataGridStateApi;
```

Instance state methods that include `tree.expandedRows` (wraps `createDataGridStateApi(engine)`).

## Classes

### TreeView

Kind: class

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeView

```ts
class TreeView implements RowModelView {
    readonly kind: 'tree';
    readonly model: TreeViewModel;
    readonly count: number;
    readonly dataCount: number;
    readonly lo: number;
    readonly hi: number;
    readonly range: readonly [
        number,
        number
    ];
    private readonly f0;
    private readonly f1;
    private byFooter;
    constructor(model: TreeViewModel, lo?: number, hi?: number, paged?: boolean);
    get layout(): TreeLayout;
    private footerIndex;
    private footerBefore;
    positionAt(index: number): number;
    get tree(): {
        readonly order: Int32Array;
        readonly sourceIds: readonly RowId[];
        readonly dataCount: number;
    };
    get dataRows(): number;
    indexOfPosition(p: number): number;
    footerOwnerAt(index: number): number;
    kindAt(index: number): RowKind;
    sourceIndexAt(index: number): number;
    idAt(index: number): RowId | undefined;
    depthAt(index: number): number;
    indexOfSource(sourceIndex: number): number;
    parentOfSource(sourceIndex: number): RowId | null;
    resolve(id: RowId): ViewRowInfo | undefined;
    isContextAt(index: number): boolean;
    exportRows(all: boolean, source: boolean): {
        readonly order: Int32Array;
        readonly depth: Uint16Array;
        readonly flags: Uint8Array | null;
        readonly maxDepth: number;
    };
    page(start: number, end: number): TreeView;
}
```

Members (28):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind: 'tree';` |  |  |
| `model` | `readonly model: TreeViewModel;` |  |  |
| `count` | `readonly count: number;` |  |  |
| `dataCount` | `readonly dataCount: number;` |  |  |
| `lo` | `readonly lo: number;` |  | Data position window `[lo, hi)` and footer window `[f0, f1)`. |
| `hi` | `readonly hi: number;` |  |  |
| `range` | `readonly range: readonly [     number,     number ];` |  | `[lo, hi)` (the page window over data positions; read by `dataIndexAt` / `dataRowIdAt` in view-helpers.ts). |
| `f0` | `private readonly f0;` |  |  |
| `f1` | `private readonly f1;` |  |  |
| `byFooter` | `private byFooter;` |  |  |
| `layout` | `get layout(): TreeLayout;` |  |  |
| `footerIndex` | `private footerIndex;` |  | Visible index of footer j (absolute footer index). |
| `footerBefore` | `private footerBefore;` |  | Largest footer j in the window with footerIndex(j) <= index, or f0 - 1. |
| `positionAt` | `positionAt(index: number): number;` |  | Data position (absolute) at a visible index, or -1 for a footer. |
| `tree` | `get tree(): {     readonly order: Int32Array;     readonly sourceIds: readonly RowId[];     readonly dataCount: number; };` |  | Visible data rows in data position order (source indexes), materialized on first read and shared by the paged views: the data order `dataRowIdAt` (view-helpers.ts) indexes, like a grouped view's tree. |
| `dataRows` | `get dataRows(): number;` |  | Visible data rows of this view (`dataCount` counts roots on an unpaged `pageBy: 'root'` view). |
| `indexOfPosition` | `indexOfPosition(p: number): number;` |  | Visible index of an absolute data position. |
| `footerOwnerAt` | `footerOwnerAt(index: number): number;` |  | Source index of the parent a footer row summarizes, or -1 when `index` is not a footer. |
| `kindAt` | `kindAt(index: number): RowKind;` |  |  |
| `sourceIndexAt` | `sourceIndexAt(index: number): number;` |  |  |
| `idAt` | `idAt(index: number): RowId \| undefined;` |  |  |
| `depthAt` | `depthAt(index: number): number;` |  |  |
| `indexOfSource` | `indexOfSource(sourceIndex: number): number;` |  |  |
| `parentOfSource` | `parentOfSource(sourceIndex: number): RowId \| null;` |  |  |
| `resolve` | `resolve(id: RowId): ViewRowInfo \| undefined;` |  |  |
| `isContextAt` | `isContextAt(index: number): boolean;` |  | True when the row at a visible index is kept only as context (an ancestor or descendant of a match). |
| `exportRows` | `exportRows(all: boolean, source: boolean): {     readonly order: Int32Array;     readonly depth: Uint16Array;     readonly flags: Uint8Array \| null;     readonly maxDepth: number; };` |  | Export rows (read duck-typed by export-model.ts, so the export code loads no tree code): source indexes in pre-order with depth by source index. `all`: every row of the window, collapsed subtrees included (a subtree is contiguous in pre-order), with `flags` by source index (1: a collapsed parent with kept children, 2: under a collapsed ancestor); else the visible rows. `source`: the full tree (every source row, the query ignored) instead of this view's window. |
| `page` | `page(start: number, end: number): TreeView;` |  | Page window. `pageBy: 'all'`: data positions `[start, end)`. `pageBy: 'root'`: root ordinals `[start, end)`, each with its visible subtree. |

## Interfaces

### TreeInfo

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeInfo

```ts
interface TreeInfo {
    readonly shape: 'nested' | 'flat';
    readonly childrenField: string | null;
    readonly parentIdField: string | null;
    readonly hasChildrenField: string | null;
    readonly column: string | null;
    readonly defaultExpanded: boolean | number;
    readonly filterMode: TreeFilterMode;
    readonly pageBy: TreePageBy;
    readonly checkbox: boolean;
    readonly cascade: TreeCascade;
    readonly copyMode: TreeFilterMode;
    readonly childSummary: boolean;
}
```

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `shape` | `readonly shape: 'nested' \| 'flat';` |  |  |
| `childrenField` | `readonly childrenField: string \| null;` |  |  |
| `parentIdField` | `readonly parentIdField: string \| null;` |  |  |
| `hasChildrenField` | `readonly hasChildrenField: string \| null;` |  |  |
| `column` | `readonly column: string \| null;` |  |  |
| `defaultExpanded` | `readonly defaultExpanded: boolean \| number;` |  |  |
| `filterMode` | `readonly filterMode: TreeFilterMode;` |  |  |
| `pageBy` | `readonly pageBy: TreePageBy;` |  |  |
| `checkbox` | `readonly checkbox: boolean;` |  |  |
| `cascade` | `readonly cascade: TreeCascade;` |  |  |
| `copyMode` | `readonly copyMode: TreeFilterMode;` |  |  |
| `childSummary` | `readonly childSummary: boolean;` |  |  |

### TreeIssue

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeIssue

```ts
interface TreeIssue {
    readonly kind: 'orphan' | 'cycle';
    readonly index: number;
}
```

A data problem found while resolving parents: an unknown parent id (`orphan`) or a parent chain that loops (`cycle`).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `kind` | `readonly kind: 'orphan' \| 'cycle';` |  |  |
| `index` | `readonly index: number;` |  | Source index of the row that became a root. |

### TreeLayout

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeLayout

```ts
interface TreeLayout {
    readonly sourceCount: number;
    readonly count: number;
    readonly order: Int32Array;
    readonly slot: Int32Array;
    readonly next: Int32Array;
    readonly parent: Int32Array;
    readonly depth: Uint16Array;
    readonly childCount: Int32Array;
    readonly posinset: Int32Array;
    readonly setsize: Int32Array;
    readonly roots: Int32Array;
}
```

Pre-order layout of the kept rows of a tree. Arrays named `by slot` are indexed by pre-order slot, the others by source index.

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `sourceCount` | `readonly sourceCount: number;` |  | Source rows the layout was built over. |
| `count` | `readonly count: number;` |  | Kept rows (slots). |
| `order` | `readonly order: Int32Array;` |  | By slot: source index. |
| `slot` | `readonly slot: Int32Array;` |  | Source index -> slot, or -1 when the row is not kept. |
| `next` | `readonly next: Int32Array;` |  | By slot: first slot after the subtree. |
| `parent` | `readonly parent: Int32Array;` |  | Effective parent (nearest kept ancestor) source index, or -1 for a root. |
| `depth` | `readonly depth: Uint16Array;` |  |  |
| `childCount` | `readonly childCount: Int32Array;` |  | Kept children. |
| `posinset` | `readonly posinset: Int32Array;` |  | 1-based ordinal among kept siblings (`aria-posinset`; 0: not kept). Built on first read. |
| `setsize` | `readonly setsize: Int32Array;` |  | Kept siblings including the row (`aria-setsize`; 0: not kept). Built on first read. |
| `roots` | `readonly roots: Int32Array;` |  | Slots of the root rows, ascending. |

### TreeLoadContext

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeLoadContext

```ts
interface TreeLoadContext<Row> {
    readonly rowId: RowId;
    readonly row: Row;
    readonly signal: AbortSignalLike;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rowId` | `readonly rowId: RowId;` |  |  |
| `row` | `readonly row: Row;` |  |  |
| `signal` | `readonly signal: AbortSignalLike;` |  |  |

### TreeOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeOptions

```ts
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;
}
```

Members (16):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `childrenField` | `readonly childrenField?: string;` | optional | Nested rows: the field holding child arrays (`tree: true` means `'children'`). The engine source must be `flattenTree(data, childrenField)`. |
| `parentIdField` | `readonly parentIdField?: string;` | optional | Flat self-referential rows: the field holding the parent's row id (root: missing, null, `''`, or unknown). |
| `hasChildrenField` | `readonly hasChildrenField?: string;` | optional | Rows whose children load on demand (`hasChildMapping`). |
| `expandedField` | `readonly expandedField?: string;` | optional | Initial expansion from a boolean data field (`expandStateMapping`); overridden by `expandedRows` and every expand command. |
| `column` | `readonly column?: string;` | optional | Field or column id of the tree column (default: the first visible data column; resolved by the renderer). |
| `defaultExpanded` | `readonly defaultExpanded?: boolean \| number;` | optional | `true` (default): every parent expanded; `false`: collapsed; `n`: rows of depth < n expanded. |
| `expandedRows` | `readonly expandedRows?: Readonly<Record<RowId, boolean>>;` | optional | Initial per-row overrides over `defaultExpanded` (reactive input through `tree.setExpanded`). |
| `filterMode` | `readonly filterMode?: TreeFilterMode;` | optional | Rows a filter or search keeps: matches with their ancestors (default), with their descendants, both, or matches only (re-parented). |
| `pageBy` | `readonly pageBy?: TreePageBy;` | optional | Paging counts every visible row (default) or root rows with their subtrees. |
| `checkbox` | `readonly checkbox?: boolean \| {     readonly cascade?: TreeCascade; };` | optional | Checkbox in the tree column; `cascade` selects subtrees (`'filtered'`: kept rows only). |
| `copyMode` | `readonly copyMode?: TreeFilterMode;` | optional | Rows `copy()` adds around the copied rows (clipboard, read by the renderer). |
| `childSummary` | `readonly childSummary?: boolean;` | optional | Child summary rows (`__tf:<rowId>`) after the last visible descendant of each expanded parent (`showChildSummary`). |
| `loadChildren` | `readonly loadChildren?: (ctx: TreeLoadContext<Row>) => readonly Row[] \| Promise<readonly Row[]>;` | optional | Loads the children of a lazy row (`hasChildrenField`). Returned rows join the data source (local sources) under the row. |
| `setParentId` | `readonly setParentId?: (row: Row, parentId: RowId \| null) => Row;` | optional | Copy of a row with a new parent (flat data writes). Default: a shallow copy with `parentIdField` set. |
| `hasChildren` | `readonly hasChildren?: (row: Row, rowId: RowId) => boolean \| undefined;` | optional | Whether a row has children to load when `hasChildrenField` cannot be read (remote envelopes, tuple rows; `createRemoteTree`). `undefined` falls back to `hasChildrenField`. |
| `parentIdOf` | `readonly parentIdOf?: (row: Row, rowId: RowId) => RowId \| null \| undefined;` | optional | 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. |

### TreeRanges

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeRanges

```ts
interface TreeRanges {
    readonly starts: Int32Array;
    readonly ends: Int32Array;
    readonly prefix: Int32Array;
    readonly total: number;
    readonly footerAt: Int32Array;
    readonly footerOwner: Int32Array;
}
```

Visible slot ranges of a layout (grid-free).

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `starts` | `readonly starts: Int32Array;` |  | Range starts and ends (slots, `[start, end)`), ascending. |
| `ends` | `readonly ends: Int32Array;` |  |  |
| `prefix` | `readonly prefix: Int32Array;` |  | `prefix[r]`: visible data rows before range r; `prefix[k]` is the total. |
| `total` | `readonly total: number;` |  | Visible data rows. |
| `footerAt` | `readonly footerAt: Int32Array;` |  | Child summary rows: data rows before footer j (ascending; ties keep inner parents first). |
| `footerOwner` | `readonly footerOwner: Int32Array;` |  | Child summary rows: source index of the parent of footer j. |

### TreeRowInfo

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeRowInfo

```ts
interface TreeRowInfo {
    readonly rowId: RowId;
    readonly depth: number;
    readonly parentId: RowId | null;
    readonly hasChildren: boolean;
    readonly childCount: number;
    readonly expanded: boolean;
    readonly loadStatus: TreeLoadStatus;
    readonly posinset: number;
    readonly setsize: number;
    readonly context: boolean;
    readonly visible: boolean;
}
```

What the renderer needs per tree row (`ctx.tree`, row ARIA, toggle). Stable identity while unchanged.

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rowId` | `readonly rowId: RowId;` |  |  |
| `depth` | `readonly depth: number;` |  |  |
| `parentId` | `readonly parentId: RowId \| null;` |  |  |
| `hasChildren` | `readonly hasChildren: boolean;` |  | Kept children, or unloaded lazy children (`hasChildrenField`). |
| `childCount` | `readonly childCount: number;` |  |  |
| `expanded` | `readonly expanded: boolean;` |  | Shown expanded: false for a lazy parent whose children were never requested, whatever its default (`isExpanded` reads the state). |
| `loadStatus` | `readonly loadStatus: TreeLoadStatus;` |  |  |
| `posinset` | `readonly posinset: number;` |  | 1-based ordinal and count among kept siblings (`aria-posinset` / `aria-setsize`). |
| `setsize` | `readonly setsize: number;` |  |  |
| `context` | `readonly context: boolean;` |  | Kept only as an ancestor or descendant of a match (`data-tree-context`). |
| `visible` | `readonly visible: boolean;` |  | Visible in the current view (not hidden by a collapsed ancestor, a filter, or the page). |

### TreeState

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeState

```ts
interface TreeState {
    readonly childrenField: string | null;
    readonly parentIdField: string | null;
    readonly hasChildrenField: string | null;
    readonly expandedField: string | null;
    readonly column: string | null;
    readonly defaultExpanded: boolean | number;
    readonly useField: boolean;
    readonly expanded: Readonly<Record<RowId, boolean>>;
    readonly filterMode: TreeFilterMode;
    readonly pageBy: TreePageBy;
    readonly checkbox: boolean;
    readonly cascade: TreeCascade;
    readonly copyMode: TreeFilterMode;
    readonly childSummary: boolean;
    readonly loadVersion: number;
}
```

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `childrenField` | `readonly childrenField: string \| null;` |  |  |
| `parentIdField` | `readonly parentIdField: string \| null;` |  |  |
| `hasChildrenField` | `readonly hasChildrenField: string \| null;` |  |  |
| `expandedField` | `readonly expandedField: string \| null;` |  |  |
| `column` | `readonly column: string \| null;` |  |  |
| `defaultExpanded` | `readonly defaultExpanded: boolean \| number;` |  |  |
| `useField` | `readonly useField: boolean;` |  | `expandedField` still applies (cleared by expand all, collapse all and an explicit default). |
| `expanded` | `readonly expanded: Readonly<Record<RowId, boolean>>;` |  | Row id -> expanded, overriding the per-row default (only values that differ from it). |
| `filterMode` | `readonly filterMode: TreeFilterMode;` |  |  |
| `pageBy` | `readonly pageBy: TreePageBy;` |  |  |
| `checkbox` | `readonly checkbox: boolean;` |  |  |
| `cascade` | `readonly cascade: TreeCascade;` |  |  |
| `copyMode` | `readonly copyMode: TreeFilterMode;` |  |  |
| `childSummary` | `readonly childSummary: boolean;` |  |  |
| `loadVersion` | `readonly loadVersion: number;` |  | Bumped when a child load or a parent override (`tree.setParents`) changes the tree. |

### TreeStructure

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeStructure

```ts
interface TreeStructure {
    readonly index: TreeLayout;
    readonly layout: TreeLayout;
    readonly sourceIds: readonly RowId[];
    sourceIndexOf(rowId: RowId): number;
    readonly parentIdField: string | null;
    readonly nested?: boolean;
    withParent(row: unknown, parentId: RowId | null): unknown;
}
```

Tree reads the selection, editing, and row drag modules use through
`treeOf(model)` (view-helpers.ts) without importing tree code: the full
(unfiltered) tree and the kept layout of the current query.

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `index` | `readonly index: TreeLayout;` |  | Every source row (unfiltered, source sibling order). |
| `layout` | `readonly layout: TreeLayout;` |  | Rows kept by the current query, in sorted sibling order. |
| `sourceIds` | `readonly sourceIds: readonly RowId[];` |  |  |
| `sourceIndexOf` | `sourceIndexOf(rowId: RowId): number;` |  | Source index of a row id, or -1. |
| `parentIdField` | `readonly parentIdField: string \| null;` |  | `parentIdField` of flat data, or null for nested data. |
| `nested` | `readonly nested?: boolean;` | optional | Parents come from the nesting (`childrenField`): moves keep the new parent through `tree.setParents`. |
| `withParent` | `withParent(row: unknown, parentId: RowId \| null): unknown;` |  | Returns a copy of `row` with its parent set (flat data), or null when the shape cannot express it (moves then dispatch `tree.setParents`). |

### TreeViewModel

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeViewModel

```ts
interface TreeViewModel {
    readonly structure: TreeStructure;
    readonly expanded: Uint8Array;
    readonly match: Uint8Array | null;
    readonly lazy: Uint8Array | null;
    readonly ranges: TreeRanges;
    readonly pageBy: 'all' | 'root';
}
```

The tree view's per-model data (shared by its paged views).

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `structure` | `readonly structure: TreeStructure;` |  |  |
| `expanded` | `readonly expanded: Uint8Array;` |  | By source index: 1 when the row is expanded. |
| `match` | `readonly match: Uint8Array \| null;` |  | By source index: 1 when the row matches the query (null: every kept row matches). Kept rows that do not match are context rows. |
| `lazy` | `readonly lazy: Uint8Array \| null;` |  | By source index: 1 when the row has children that are not loaded (lazy), or null. |
| `ranges` | `readonly ranges: TreeRanges;` |  |  |
| `pageBy` | `readonly pageBy: 'all' \| 'root';` |  | `root`: the page stage pages root rows. The unpaged view then reports the root count as `dataCount` (the page stage's unit); its paged windows report their data rows. |

## Types

### TreeCascade

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCascade

```ts
type TreeCascade = boolean | 'filtered';
```

### TreeCheckCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCheckCommand

```ts
type TreeCheckCommand = {
    type: 'tree.check';
    rowId: RowId;
    checked?: boolean;
};
```

Checkbox toggle: with a cascade, the row's subtree in one selection update and the derived ancestors.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.check';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |
| `checked` | `checked?: boolean;` | optional |  |

### TreeCheckState

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCheckState

```ts
type TreeCheckState = 'checked' | 'mixed' | 'unchecked';
```

### TreeCollapseAllCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCollapseAllCommand

```ts
type TreeCollapseAllCommand = {
    type: 'tree.collapseAll';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.collapseAll';` |  |  |

### TreeCollapseCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCollapseCommand

```ts
type TreeCollapseCommand = {
    type: 'tree.collapse';
} & IdTarget;
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: "tree.collapse";` | inherited |  |
| `rowId` | `rowId?: string;` | optional, inherited |  |
| `rowIds` | `rowIds?: string[];` | optional, inherited |  |

### TreeCollapseFocusedCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCollapseFocusedCommand

```ts
type TreeCollapseFocusedCommand = {
    type: 'tree.collapseFocused';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.collapseFocused';` |  |  |

### TreeCollapseLevelCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCollapseLevelCommand

```ts
type TreeCollapseLevelCommand = {
    type: 'tree.collapseLevel';
    depth: number;
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.collapseLevel';` |  |  |
| `depth` | `depth: number;` |  |  |

### TreeCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeCommand

```ts
type TreeCommand = TreeExpandCommand | TreeCollapseCommand | TreeToggleCommand | TreeExpandAllCommand | TreeCollapseAllCommand | TreeExpandLevelCommand | TreeCollapseLevelCommand | TreeSetExpandedCommand | TreeSetOptionsCommand | TreeIndentCommand | TreeOutdentCommand | TreeLoadChildrenCommand | TreeRetryCommand | TreeLoadedCommand | TreeSetParentsCommand | TreeCheckCommand | TreeExpandFocusedCommand | TreeCollapseFocusedCommand;
```

### TreeExpandAllCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeExpandAllCommand

```ts
type TreeExpandAllCommand = {
    type: 'tree.expandAll';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.expandAll';` |  |  |

### TreeExpandCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeExpandCommand

```ts
type TreeExpandCommand = {
    type: 'tree.expand';
} & IdTarget;
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: "tree.expand";` | inherited |  |
| `rowId` | `rowId?: string;` | optional, inherited |  |
| `rowIds` | `rowIds?: string[];` | optional, inherited |  |

### TreeExpandFocusedCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeExpandFocusedCommand

```ts
type TreeExpandFocusedCommand = {
    type: 'tree.expandFocused';
};
```

Key commands: expand / collapse the focused row.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.expandFocused';` |  |  |

### TreeExpandLevelCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeExpandLevelCommand

```ts
type TreeExpandLevelCommand = {
    type: 'tree.expandLevel';
    depth: number;
};
```

Expands (collapses) every parent at `depth` (0: roots).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.expandLevel';` |  |  |
| `depth` | `depth: number;` |  |  |

### TreeFilterMode

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeFilterMode

```ts
type TreeFilterMode = 'ancestors' | 'descendants' | 'both' | 'none';
```

### TreeIndentCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeIndentCommand

```ts
type TreeIndentCommand = {
    type: 'tree.indent';
    rowIds: RowId[];
};
```

Moves rows as the last children of their previous sibling (requires the `rowDragDrop` module).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.indent';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |

### TreeLoadChildrenCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeLoadChildrenCommand

```ts
type TreeLoadChildrenCommand = {
    type: 'tree.loadChildren';
    rowId: RowId;
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.loadChildren';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |

### TreeLoadStatus

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeLoadStatus

```ts
type TreeLoadStatus = 'idle' | 'loading' | 'loaded' | 'error';
```

### TreeLoadedCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeLoadedCommand

```ts
type TreeLoadedCommand = {
    type: 'tree.loaded';
    rowId: RowId;
    status: 'loading' | 'loaded' | 'error' | 'idle';
    childIds?: RowId[];
    error?: string;
};
```

A child load settled (dispatched by the module; also the hook for data
layers that load children through their own channel). `childIds` names
rows that join `rowId` without carrying the relation in their data.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.loaded';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |
| `status` | `status: 'loading' \| 'loaded' \| 'error' \| 'idle';` |  |  |
| `childIds` | `childIds?: RowId[];` | optional |  |
| `error` | `error?: string;` | optional |  |

### TreeMethods

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeMethods

```ts
type TreeMethods<Row> = {
    getTreeRow(ctx: ModuleContext<Row>, rowId: RowId): TreeRowInfo | null;
    getChildRows(ctx: ModuleContext<Row>, rowId: RowId | null): readonly Row[];
    getChildRowIds(ctx: ModuleContext<Row>, rowId: RowId | null): readonly RowId[];
    isExpanded(ctx: ModuleContext<Row>, rowId: RowId): boolean;
    getLoadStatus(ctx: ModuleContext<Row>, rowId: RowId): TreeLoadStatus;
    checkState(ctx: ModuleContext<Row>, rowId: RowId): TreeCheckState;
    getChildSummary(ctx: ModuleContext<Row>, rowId: RowId): AggregateValues | null;
    canIndent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;
    canOutdent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;
    getExpansion(ctx: ModuleContext<Row>): {
        readonly expandedRows: Readonly<Record<RowId, boolean>>;
        readonly defaultExpanded: boolean | number;
    };
    getInfo(ctx: ModuleContext<Row>): TreeInfo;
};
```

Members (11):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `getTreeRow` | `getTreeRow(ctx: ModuleContext<Row>, rowId: RowId): TreeRowInfo \| null;` |  | Row info for the renderer and `getRowInfo()`; null for unknown rows. |
| `getChildRows` | `getChildRows(ctx: ModuleContext<Row>, rowId: RowId \| null): readonly Row[];` |  | Kept children of a row in view order (null: the roots). |
| `getChildRowIds` | `getChildRowIds(ctx: ModuleContext<Row>, rowId: RowId \| null): readonly RowId[];` |  |  |
| `isExpanded` | `isExpanded(ctx: ModuleContext<Row>, rowId: RowId): boolean;` |  |  |
| `getLoadStatus` | `getLoadStatus(ctx: ModuleContext<Row>, rowId: RowId): TreeLoadStatus;` |  |  |
| `checkState` | `checkState(ctx: ModuleContext<Row>, rowId: RowId): TreeCheckState;` |  | Checkbox tri-state derived from selected descendants (`aria-checked="mixed"`). |
| `getChildSummary` | `getChildSummary(ctx: ModuleContext<Row>, rowId: RowId): AggregateValues \| null;` |  | Child summary values of a parent (over its kept descendants), or null without aggregates. |
| `canIndent` | `canIndent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;` |  | Can `tree.indent` / `tree.outdent` move these rows (toolbar disabled state)? |
| `canOutdent` | `canOutdent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;` |  |  |
| `getExpansion` | `getExpansion(ctx: ModuleContext<Row>): {     readonly expandedRows: Readonly<Record<RowId, boolean>>;     readonly defaultExpanded: boolean \| number; };` |  | Persistable expansion (`getState().tree`). |
| `getInfo` | `getInfo(ctx: ModuleContext<Row>): TreeInfo;` |  |  |

### TreeModule

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeModule

```ts
type TreeModule<Row> = DataGridModule<Row, TreeState, TreeCommand, 'tree', TreeMethods<Row>>;
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `name` | `name: "tree";` | inherited |  |
| `dependencies` | `dependencies?: readonly string[];` | optional, inherited | Validated at engine creation. |
| `inSnapshot` | `inSnapshot?: boolean;` | optional, inherited | When true (default) the slice lives in `snapshot.modules[name]` and every change replaces the grid snapshot. High-churn modules (focus, selection, drafts) set false and notify through row/cell/header/module channels only. |
| `commands` | `commands: readonly ("tree.check" \| "tree.collapse" \| "tree.collapseAll" \| "tree.collapseFocused" \| "tree.collapseLevel" \| "tree.expand" \| "tree.expandAll" \| "tree.expandFocused" \| "tree.expandLevel" \| ... 8 more ... \| "tree.toggle")[];` | inherited | Declared, validated, serializable. Every type must start with `${name}.`. |
| `initialState` | `initialState: (options: DataGridOptions<Row>) => TreeState;` | inherited |  |
| `reduce` | `reduce?: ((state: TreeState, command: TreeCommand, ctx: ModuleContext<Row>) => CommandRejection \| TreeState);` | optional, inherited |  |
| `extendColumns` | `extendColumns?: ((columns: readonly CompiledColumn<Row>[], ctx: ModuleContext<Row>) => readonly CompiledColumn<Row>[]);` | optional, inherited |  |
| `extendQuery` | `extendQuery?: ((query: DataQuery, state: TreeState) => DataQuery);` | optional, inherited |  |
| `pipeline` | `pipeline?: readonly PipelineStage<Row, TreeState>[];` | optional, inherited |  |
| `selectors` | `selectors?: Readonly<Record<string, (snapshot: DataGridSnapshot<Row>) => unknown>>;` | optional, inherited |  |
| `methods` | `methods?: TreeMethods<Row>;` | optional, inherited | Reads that need more than the snapshot (facets, pager totals). Must not change state; names may not collide with command actions. |
| `notify` | `notify?: ((previous: TreeState, next: TreeState, ctx: ModuleContext<Row>) => NotificationScope);` | optional, inherited |  |
| `hiddenColumns` | `hiddenColumns?: ((state: TreeState) => readonly string[]);` | optional, inherited | Leaf columns this module hides from the visible column set (grouped columns with `showGroupedColumns: false`). |
| `interceptRead` | `interceptRead?: ((query: DataQuery, state: TreeState, ctx: ModuleContext<Row>) => boolean);` | optional, inherited | Remote sources only: return true to serve the main read of `query` yourself (lazy grouping loads group levels instead of rows). The engine then shows no source rows and runs only the stages the source did not perform. |
| `onQueryChange` | `onQueryChange?: ((previous: DataQuery, next: DataQuery, ctx: ModuleContext<Row>) => void);` | optional, inherited | Called after the effective query changed (sort, filter, search, page, group). Runs inside the dispatch of the command that changed it; may dispatch commands through `ctx` (selection clears itself here when it does not persist). |
| `onConnect` | `onConnect?: ((ctx: ModuleContext<Row>) => void);` | optional, inherited | `engine.connect()` ran (`deferDataSource`): start loads that were held while disconnected. |
| `onSourceEvent` | `onSourceEvent?: ((event: DataSourceEvent<Row>, state: TreeState, ctx: ModuleContext<Row>) => boolean);` | optional, inherited | A data source event (patch or reset). Return true to consume it: the engine then leaves its source rows unchanged (infinite scroll applies write echoes to the blocks it owns). |
| `dispose` | `dispose?: (() => void);` | optional, inherited |  |

### TreeOutdentCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeOutdentCommand

```ts
type TreeOutdentCommand = {
    type: 'tree.outdent';
    rowIds: RowId[];
};
```

Moves rows to just after their parent, as its siblings (requires the `rowDragDrop` module).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.outdent';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |

### TreePageBy

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreePageBy

```ts
type TreePageBy = 'all' | 'root';
```

### TreeRetryCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeRetryCommand

```ts
type TreeRetryCommand = {
    type: 'tree.retry';
    rowId: RowId;
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.retry';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |

### TreeSetExpandedCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeSetExpandedCommand

```ts
type TreeSetExpandedCommand = {
    type: 'tree.setExpanded';
    expanded: {
        [rowId: string]: boolean;
    };
    defaultExpanded?: boolean | number;
};
```

Controlled expansion: replaces the overrides (and optionally the default).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.setExpanded';` |  |  |
| `expanded` | `expanded: {     [rowId: string]: boolean; };` |  |  |
| `defaultExpanded` | `defaultExpanded?: boolean \| number;` | optional |  |

### TreeSetOptionsCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeSetOptionsCommand

```ts
type TreeSetOptionsCommand = {
    type: 'tree.setOptions';
    filterMode?: TreeFilterMode;
    pageBy?: TreePageBy;
    defaultExpanded?: boolean | number;
    checkbox?: boolean;
    cascade?: TreeCascade;
    copyMode?: TreeFilterMode;
    childSummary?: boolean;
    column?: string | null;
};
```

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.setOptions';` |  |  |
| `filterMode` | `filterMode?: TreeFilterMode;` | optional |  |
| `pageBy` | `pageBy?: TreePageBy;` | optional |  |
| `defaultExpanded` | `defaultExpanded?: boolean \| number;` | optional |  |
| `checkbox` | `checkbox?: boolean;` | optional |  |
| `cascade` | `cascade?: TreeCascade;` | optional |  |
| `copyMode` | `copyMode?: TreeFilterMode;` | optional |  |
| `childSummary` | `childSummary?: boolean;` | optional |  |
| `column` | `column?: string \| null;` | optional |  |

### TreeSetParentsCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeSetParentsCommand

```ts
type TreeSetParentsCommand = {
    type: 'tree.setParents';
    parents: {
        [rowId: string]: RowId | null;
    };
};
```

Parents the data does not carry (row id -> parent id, null: root): row
moves of nested (`childrenField`) or `parentIdOf` rows dispatch it, since
their write cannot change the nesting. Overrides last until disposal.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.setParents';` |  |  |
| `parents` | `parents: {     [rowId: string]: RowId \| null; };` |  |  |

### TreeStatePart

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeStatePart

```ts
type TreeStatePart = NonNullable<DataGridState['tree']>;
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `expandedRows` | `expandedRows: Readonly<Record<string, boolean>>;` | inherited |  |
| `defaultExpanded` | `defaultExpanded: number \| boolean;` | inherited |  |

### TreeToggleCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TreeToggleCommand

```ts
type TreeToggleCommand = {
    type: 'tree.toggle';
    rowId: RowId;
    expanded?: boolean;
};
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'tree.toggle';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |
| `expanded` | `expanded?: boolean;` | optional |  |

## Constants

### TREE_COMMANDS

Kind: const

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TREE_COMMANDS

```ts
const TREE_COMMANDS: readonly TreeCommand['type'][];
```

### TREE_DEFAULT_KEY

Kind: const

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TREE_DEFAULT_KEY

```ts
const TREE_DEFAULT_KEY = "*";
```

Reserved `query.expansion.tree` key carrying a boolean `defaultExpanded`; `'*<n>': true` carries a depth default.

### TREE_FOOTER_ID_PREFIX

Kind: const

Page: https://salmonui.dev/docs/reference/data-grid/engine-tree/TREE_FOOTER_ID_PREFIX

```ts
const TREE_FOOTER_ID_PREFIX = "__tf:";
```

Id prefix of tree child summary rows.
