Skip to main content

Expand and Collapse Nodes

  • 2 minutes to read

The TreeListView allows users to expand/collapse parent nodes to show/hide their children:

Run Demo: TreeList View

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.


Expand and Collapse Nodes in Code

Use the following API to expand/collapse nodes in code:

API Description
TreeListNodeBase.IsExpanded Gets or sets whether the node is expanded.
TreeListView.ExpandNode / TreeListView.CollapseNode Expands/collapses a node.
TreeListView.ChangeNodeExpanded Gets or sets the expanded state of a node.
TreeListView.ExpandToLevel Expands the parent nodes down to the specified nesting level.
TreeListNodeBase.ExpandAll / TreeListNodeBase.CollapseAll Expands/collapses all child nodes within the node.
TreeListView.ExpandAllNodes / TreeListView.CollapseAllNodes Expands/collapses all nodes within the TreeListView.
TreeListView.AutoExpandAllNodes Gets or sets whether all nodes are automatically expanded when the TreeListView is loading.

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.

View Example: Load Nodes Dynamically

Expand State

Use the following properties to bind node expand states to a property:

Property Description
TreeListView.ExpandStateBinding Gets or sets the binding that determines which nodes are expanded.
TreeListView.ExpandStateFieldName Gets or sets the name of the data source’s field that determines which nodes are expanded.


The TreeListView.ExpandStateBinding property takes precedence over the TreeListView.ExpandStateFieldName property.

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.


Topic: Filter Nodes