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

> The TreeModule type of @salmonui/data-grid/engine/tree.

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

```ts
import type { TreeModule } 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: type

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