# NestedTableState

**Category:** Base Components/Collections/NestedTable

## API

### Overview

`NestedTableState` manages the state for a [`NestedTable`](./?path=/story/base-components-collections-nestedtable--nestedtable) component. It handles multi-level hierarchical data with expand/collapse, flat and nested view modes, toolbar, and optimistic actions. Created by [`useNestedTable`](./?path=/story/base-components-collections-nestedtable-usenestedtable--usenestedtable).

### Props

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `toolbar` | `ToolbarCollectionState<unknown, {}>` | Yes | - | Underlying [ToolbarCollectionState](./?path=/story/common-state--toolbarcollectionstate) instance |
| `tableState` | `TableState<unknown, {}>` | Yes | - | Underlying [TableState](./?path=/story/base-components-collections-table-tablestate--tablestate) instance |
| `getNode` | `<TD, FD extends FiltersMap>(key: string) => NestedTableNodeStatePublicAPI<C, TD, FD> \| undefined` | Yes | - | Get the node this item is the parent of. i.e. this node's collection items' parent id is the `key` @param key string) => [NestedTableNodeState](./?path=/story/base-components-collections-nestedtable--nestedtablenodestate) \| undefined |
| `getRootNode` | `<TD, FD extends FiltersMap>() => NestedTableNodeStatePublicAPI<C, TD, FD>` | Yes | - | Get the root node of the nested table, this node's collection items' parent id is `null`, the items are the top level items |
| `getAllNodes` | `<TD, FD extends FiltersMap>() => NestedTableNodeStatePublicAPI<C, TD, FD>[]` | Yes | - | Get all the nodes in the table |
| `refreshAll` | `() => void` | Yes | - | An API to refresh all items in the nested table. |

