# DataGridTreeApi (@salmonui/data-grid)

> The DataGridTreeApi interface of @salmonui/data-grid: Tree methods of DataGridApi (rejected or empty without tree).

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

```ts
import type { DataGridTreeApi } 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 DataGridTreeApi<Row> {
    expandAllTreeRows(): DataGridActionResult;
    collapseAllTreeRows(): DataGridActionResult;
    expandTreeLevel(depth: number): DataGridActionResult;
    collapseTreeLevel(depth: number): DataGridActionResult;
    expandTreeRows(rowIds: RowId | readonly RowId[]): DataGridActionResult;
    collapseTreeRows(rowIds: RowId | readonly RowId[]): DataGridActionResult;
    toggleTreeRow(rowId: RowId, expanded?: boolean): DataGridActionResult;
    indentRows(rowIds: RowId | readonly RowId[]): DataGridActionResult;
    outdentRows(rowIds: RowId | readonly RowId[]): DataGridActionResult;
    getTreeRow(rowId: RowId): DataGridTreeRowInfo | null;
    getChildRows(rowId: RowId | null): readonly Row[];
    reloadTreeChildren(rowId: RowId): DataGridActionResult;
    getVisibleRows(): readonly Row[];
}
```

Tree methods of `DataGridApi` (rejected or empty without `tree`).

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `expandAllTreeRows` | `expandAllTreeRows(): DataGridActionResult;` |  |  |
| `collapseAllTreeRows` | `collapseAllTreeRows(): DataGridActionResult;` |  |  |
| `expandTreeLevel` | `expandTreeLevel(depth: number): DataGridActionResult;` |  | Expands the parents at `depth` (0: roots). |
| `collapseTreeLevel` | `collapseTreeLevel(depth: number): DataGridActionResult;` |  |  |
| `expandTreeRows` | `expandTreeRows(rowIds: RowId \| readonly RowId[]): DataGridActionResult;` |  |  |
| `collapseTreeRows` | `collapseTreeRows(rowIds: RowId \| readonly RowId[]): DataGridActionResult;` |  |  |
| `toggleTreeRow` | `toggleTreeRow(rowId: RowId, expanded?: boolean): DataGridActionResult;` |  |  |
| `indentRows` | `indentRows(rowIds: RowId \| readonly RowId[]): DataGridActionResult;` |  | Moves rows under their previous sibling. |
| `outdentRows` | `outdentRows(rowIds: RowId \| readonly RowId[]): DataGridActionResult;` |  | Moves rows after their parent, as its siblings. |
| `getTreeRow` | `getTreeRow(rowId: RowId): DataGridTreeRowInfo \| null;` |  |  |
| `getChildRows` | `getChildRows(rowId: RowId \| null): readonly Row[];` |  | Kept children of a row in view order (`null`: the roots). |
| `reloadTreeChildren` | `reloadTreeChildren(rowId: RowId): DataGridActionResult;` |  | *Salmon*: retries a failed lazy child load. |
| `getVisibleRows` | `getVisibleRows(): readonly Row[];` |  | Visible data rows in view order. |
