DxTreeView.GetNodeExpanded(Func<ITreeViewNodeInfo, Boolean>) Method
Returns whether the specified node is expanded.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool GetNodeExpanded(
Func<ITreeViewNodeInfo, bool> predicate
)
Parameters
Name | Type | Description |
---|---|---|
predicate | Func<ITreeViewNodeInfo, Boolean> | A method delegate that specifies a particular node. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
<DxTreeView @ref="@treeView"
AllowSelectNodes="true"
BeforeCollapse="@BeforeExpandCollapse"
BeforeExpand="@BeforeExpandCollapse"
SelectionChanged="@SelectionChanged">
@* ... *@
</DxTreeView>
@code {
DxTreeView treeView;
protected void SelectionChanged(TreeViewNodeEventArgs e) {
if (e.NodeInfo.IsLeaf && e.NodeInfo.Level == 0) {
treeView.CollapseAll();
}
else if (!e.NodeInfo.IsLeaf) {
Func<ITreeViewNodeInfo, bool> nodePredicate = n => string.Equals(n.Text, e.NodeInfo.Text);
bool nodeExpanded = treeView.GetNodeExpanded(nodePredicate);
if (!nodeExpanded) {
treeView.CollapseAll();
}
treeView.SetNodeExpanded(nodePredicate, !nodeExpanded);
}
}
protected void BeforeExpandCollapse(TreeViewNodeCancelEventArgs e) {
e.Cancel = true;
}
}
Note
This method is not in effect if Load Child Nodes on Demand mode is enabled, and the specified node is not loaded yet.
See Also