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
Collapses all the nodes in the tree. See related expandAll
prop.
collapseNode
Collapses the node with the given node path. See related expandNode
and toggleNode
methods.
deselectAll
Deselects all the nodes in the tree. See related selectAll
prop.
deselectNode
Deselects the node with the given node path. See related selectNode
and toggleNodeSelection
methods.
expandAll
Expands all the nodes in the tree. See related collapseAll
prop.
expandNode
Expands the node with the given node path. See related collapseNode
and toggleNode
methods.
isNodeExpanded
Returns true
if the node is expanded, false
otherwise.
selectAll
Selects all the nodes in the tree. See related deselectAll
prop.
selectNode
Selects the node with the given node path. See related deselectNode
and toggleNodeSelection
methods.
toggleNode
Toggles the node with the give node path.
toggleNodeSelection
Toggles the selection state of the node with the given node path. See related selectNode
and deselectNode
methods.