Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
Expand/Collapse children on client
posted

On the server side api, each DataTreeNode has the methods ExpandChildren and CollapseChildren.  Is there equivalent functionality in the client-side api?  I see that a node has as toggle() method.  Will I need to simply iterate through them calling this toggle each time?

Thanks,

Rob Quick

Parents
  • 33839
    Verified Answer
    posted

    Rob,

    It is correct that there is no corresponding function on the client to accomplish that.  You will have to iterate through the descendants and expand each one.  However, calling toggle() would be incorrect.  This switches the expanded status of a node.  So if a child of the node whose children you are expanding is already expanded, it will then be collapsed.  You'll want to call .set_expanded(true).  I have written a small recursive function that will expand or collapse the children of the given node.

    function expandChildren(node, expanded) {
                node.set_expanded(expanded, true, true);
                var child = node.get_childNode(0);
                while (child != null) {
                    expandChildren(child, expanded);
                    child = child.get_nextNode();
                }
            }

     

    regards,
    Dave Young

Reply Children
No Data