DxTreeViewBase.SetNodeExpanded(Func<ITreeViewNodeInfo, Boolean>, Boolean) Method

Expands or collapses the specified node.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.dll


public void SetNodeExpanded(
    Func<ITreeViewNodeInfo, bool> predicate,
    bool expanded


Name Type Description
predicate Func<ITreeViewNodeInfo, Boolean>

A method delegate that specifies a particular node.

expanded Boolean

true, to expand a node; false, to collapse a node.


Use the SetNodeExpanded method to expand ar collapse a node programmatically.

The code sample below demonstrates how to expand a selected node if it has children.

<DxTreeView @ref="@SampleTreeView" AllowSelectNodes="true" SelectionChanged="@SelectionChanged">

@code  {
    DxTreeView SampleTreeView;

    protected void SelectionChanged(TreeViewNodeEventArgs e)
        SampleTreeView.ExpandToNode((n) => n.Text == e.NodeInfo.Text);

        if (!SampleTreeView.GetSelectedNodeInfo().IsLeaf) {
            SampleTreeView.SetNodeExpanded((n) => n.Text == e.NodeInfo.Text, true);
See Also