DxTreeViewBase.GetNodeExpanded(Func<ITreeViewNodeInfo, Boolean>) Method
Returns whether the specified node is expanded.
Namespace: DevExpress.Blazor.Base
Assembly: DevExpress.Blazor.dll
Declaration
public bool GetNodeExpanded(
Func<ITreeViewNodeInfo, bool> predicate
)
Parameters
Returns
Type |
Description |
Boolean |
true, if the node is expanded; false, if the node is collapsed.
|
<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;
}
}
Example on GitHub
Demo Navigation Menu
See Also