# DataGridTree (@salmonui/data-grid)

> The DataGridTree interface of @salmonui/data-grid: tree prop (true: { childrenField: 'children' }).

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

```ts
import type { DataGridTree } from '@salmonui/data-grid';
```

Entry index: https://salmonui.dev/docs/reference/data-grid (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid.md).

## Reference

Kind: interface

```ts
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' }`).

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `childrenField` | `readonly childrenField?: string;` | optional | Nested rows: the field holding child arrays. Default `'children'` unless `parentIdField` is set. |
| `parentIdField` | `readonly parentIdField?: string;` | optional | Flat self-referential rows: the field holding the parent's row id (`parentIdMapping`); the id is `getRowId`. |
| `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`). |
| `column` | `readonly column?: string;` | optional | Field or column id of the tree column (`treeColumnIndex`). Default: the first visible data column; follows reorder, pinning and hiding. |
| `defaultExpanded` | `readonly defaultExpanded?: boolean \| number;` | optional | `true` (default): parents expanded; `false`: collapsed (`enableCollapseAll`); `n`: depths below `n` expanded. |
| `expandedRows` | `readonly expandedRows?: Readonly<Record<RowId, boolean>>;` | optional | *Salmon*: reactive expansion overrides over `defaultExpanded`. |
| `filterMode` | `readonly filterMode?: DataGridTreeFilterMode;` | optional | Rows a filter or search keeps (`filterSettings.hierarchyMode`). Default `'ancestors'`. |
| `pageBy` | `readonly pageBy?: 'all' \| 'root';` | optional | Paging counts every visible row (default) or root rows with their subtrees (`pageSizeMode`). |
| `checkbox` | `readonly checkbox?: boolean \| {     readonly cascade?: boolean \| 'filtered'; };` | optional | Checkbox in the tree column (column `showCheckbox`); its state is the row selection. `cascade` selects subtrees (`hierarchyCheckboxMode`). |
| `copyMode` | `readonly copyMode?: DataGridTreeFilterMode;` | optional | Rows `copy()` adds around the copied rows (`copyHierarchyMode`). Default `'ancestors'`. |
| `loadChildren` | `readonly loadChildren?: (ctx: DataGridTreeLoadContext<Row>) => readonly Row[] \| Promise<readonly Row[]>;` | optional | 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. |
