# setTreeNodeExpanded

Expands or collapses a tree node by path. Leaf nodes and missing paths cannot be expanded.

Canonical: https://grid.syidax.com/docs/methods/setTreeNodeExpanded/

<a id="meaning"></a>

## What does this API do?

Expands or collapses a tree node by path. Leaf nodes and missing paths cannot be expanded.

API for Pro features: Tree data

<a id="contract"></a>

## Exact input and result types

```typescript
setTreeNodeExpanded(path: readonly string[], expanded: boolean): Promise<void>
```

| Arguments | Required | Type |
| --- | --- | --- |
| path | Required | readonly string[] |
| expanded | Required | boolean |

The return type is `Promise<void>`.

<a id="usage"></a>

## Usage flow

After registering and initializing the Grid element, call grid.setTreeNodeExpanded(…). Read the return value with await. For methods returning a boolean or report, inspect the result before continuing.

<a id="recipes"></a>

## Feature explanations and examples

- [Tree data](https://grid.syidax.com/docs/features/tree-data.md) — Trees display parent-child data, such as folders or organizations, with indentation and expansion controls. Unlike grouping equal values, the parent relationship already exists in the data.
