Skip to main content

DxTreeView.GetSelectedNodeInfo() Method

Returns information about the selected node.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public ITreeViewNodeInfo GetSelectedNodeInfo()

Returns

Type Description
ITreeViewNodeInfo

An object that contains information about the selected node.

Remarks

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

<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);
        }    
    }
}
See Also