Tree API

When rendering the TreeDataSource component, you can get access to the Tree API by reading it from the DataSource API treeApi property.

<DataSource<DATA_TYPE>
  onReady={(api: DataSourceApi<DATA_TYPE>) => {
    api.treeApi // <----
    // treeApi is accessible here
    // you may want to store a reference to it in a ref or somewhere in your app state
    
  }}
/>

For updating tree nodes, see the following methods:

collapseAll

() => void

Collapses all the nodes in the tree. See related expandAll prop.

collapseNode

(nodePath: NodePath) => void

Collapses the node with the given node path. See related expandNode and toggleNode methods.

deselectAll

() => void

Deselects all the nodes in the tree. See related selectAll prop.

deselectNode

(nodePath: NodePath) => void

Deselects the node with the given node path. See related selectNode and toggleNodeSelection methods.

expandAll

() => void

Expands all the nodes in the tree. See related collapseAll prop.

expandNode

(nodePath: NodePath) => void

Expands the node with the given node path. See related collapseNode and toggleNode methods.

isNodeExpanded

(nodePath: NodePath) => boolean

Returns true if the node is expanded, false otherwise.

selectAll

() => void

Selects all the nodes in the tree. See related deselectAll prop.

selectNode

(nodePath: NodePath) => void

Selects the node with the given node path. See related deselectNode and toggleNodeSelection methods.

toggleNode

(nodePath: NodePath) => void

Toggles the node with the give node path.

toggleNodeSelection

(nodePath: NodePath) => void

Toggles the selection state of the node with the given node path. See related selectNode and deselectNode methods.