Expand Only One Node per Level | RadTreeView for ASP.NET AJAX Documentation
Edit this page

Expand Only One Node per Level

This article shows hot to expand only one Node per Level with JavaScript. Hook to the OnClientNodeClicking event of the TreeView and handle it in the following way:

function OnClientNodeClicking(sender, eventArgs) {
    var node = eventArgs.get_node();

    node.toggle();

    if (node.get_nodes().get_count()) {
        CollapseSiblings(node);
    }
}

function CollapseSiblings(node) {
    var parent = node.get_parent();
    var siblings = parent.get_nodes();
    var siblingsCount = siblings.get_count();

    for (var nodeIndex = 0; nodeIndex < siblingsCount; nodeIndex++)
     {
        var siblingNode = siblings.getNode(nodeIndex);

        if ((siblingNode != node) && (siblingNode.get_expanded())) 
        {
            siblingNode.collapse();
            return;
        }
    }
}
Is this article helpful? No Yes
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy