# TreeStructure (@salmonui/data-grid/engine/tree)

> The TreeStructure interface of @salmonui/data-grid/engine/tree: 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.

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

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

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

## Reference

Kind: interface

```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`). |
