Expand and Collapse Nodes
- 2 minutes to read
The TreeListView allows users to expand/collapse parent nodes to show/hide their children:
#Expand and Collapse Nodes in UI
Users can expand/collapse nodes as follows:
- Click a node’s expand button.
- Focus a node and press Ctrl + Left / Right.
Note
- If the Data
View property value is Row, users can press Left / Right without Ctrl to expand/collapse nodes.Base. Navigation Style - If the Tree
List property value is true, users can press Left / Right without Ctrl to expand/collapse nodes regardless of the DataView. Expand Collapse Nodes On Navigation View property value.Base. Navigation Style
#Expand and Collapse Nodes in Code
Use the following API to expand/collapse nodes in code:
API | Description |
---|---|
Tree |
Gets or sets whether the node is expanded. |
Tree |
Expands/collapses a node. |
Tree |
Gets or sets the expanded state of a node. |
Tree |
Expands the parent nodes down to the specified nesting level. |
Tree |
Expands/collapses all child nodes within the node. |
Tree |
Expands/collapses all nodes within the Tree |
Tree |
Gets or sets whether all nodes are automatically expanded when the Tree |
Before a node is expanded/collapsed, the TreeListView.NodeExpanding / TreeListView.NodeCollapsing event is raised.
After a node is expanded/collapsed, the TreeListView.NodeExpanded / TreeListView.NodeCollapsed event is raised.
#Expand State
Use the following properties to bind node expand states to a property:
Property | Description |
---|---|
Tree |
Gets or sets the binding that determines which nodes are expanded. |
Tree |
Gets or sets the name of the data source’s field that determines which nodes are expanded. |
Note
The Tree
#Related API
#EnableDynamicLoading Property
The TreeListView in hierarchical binding mode creates child nodes dynamically when you expand their parent node.
Set the TreeListView.EnableDynamicLoading property to false to create all nodes at once when the tree is loading.
#FetchSublevelChildrenOnExpand Property
The TreeListView in hierarchical binding mode fetches child nodes of sub-level nodes when you expand their parent node.
If the TreeListView.FetchSublevelChildrenOnExpand property is false, all the child nodes display expand buttons (even if they do not have children) after you expand their parent node. The expand button is hidden when you expand a sub-level node that does not contain child nodes.
The TreeListView.HasChildNodesPath property allows you to control expand buttons when sub-level children are not fetched.
#ExpandNodesOnFiltering Property
Set the TreeListView.ExpandNodesOnFiltering property to true to expand a node if its child nodes contain the search text.
Tip
Topic: Filter Nodes