Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeView.ExpandToNode(Func<ITreeViewNodeInfo, Boolean>) Method

Expands the nodes down to the specified node.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
public void ExpandToNode(
    Func<ITreeViewNodeInfo, bool> predicate
)

#Parameters

Name Type Description
predicate Func<ITreeViewNodeInfo, Boolean>

A method delegate that specifies a particular node.

#Remarks

The following code snippet expands a selected node if it has children.

Razor
<DxTreeView @ref="@SampleTreeView" AllowSelectNodes="true" SelectionChanged="@SelectionChanged">
    @* ... *@
</DxTreeView>

@code  {
    DxTreeView SampleTreeView;

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

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

Note

This method does not expand the specified node if Load Child Nodes on Demand mode is enabled, and the node is not loaded yet.

See Also