Skip to main content
All docs
V24.1

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

Checks or unchecks the specified nodes.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public void SetNodesChecked(
    Func<ITreeViewNodeInfo, bool> predicate,
    bool check
)

Parameters

Name Type Description
predicate Func<ITreeViewNodeInfo, Boolean>

A method delegate that specifies particular nodes.

check Boolean

true to check nodes; false to uncheck nodes.

Remarks

Use the SetNodesChecked method to check or uncheck the specified nodes in code.

The following code snippet expands the specified node and checks all its child nodes:

@using TreeView.Data

<DxTreeView @ref="MyTreeView"
            Data=@DataFlatSource.DataFlat
            CheckMode="TreeViewCheckMode.Multiple">
    <DataMappings>
        <DxTreeViewDataMapping Text="Product"
                               Key="Id"
                               ParentKey="ParentId" />
    </DataMappings>
</DxTreeView>

@code {
    DxTreeView MyTreeView;

    protected override void OnAfterRender(bool firstRender) {
        base.OnAfterRender(firstRender);
        if(firstRender) {
            MyTreeView.SetNodeExpanded(n => n.Text == "Clothing", true);
            MyTreeView.SetNodesChecked(n => n.Parent?.Text == "Clothing", true);
        }
    }
}
See Also