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
120
How to make the all child nodes checked when the parent node is checked with Javascript?
posted

Now I use the ultrawebtree with checkboxes in my code.I want to  make the all child nodes checked when parent node is checked with Javascript. Ultrawebtree'samples show me some case.But the case are server side event,now I want to get the  some client side event's case.So I want to get some case with Javascript,thanks!

 

 

  • 25
    posted

     Hey tianshuo,

    You can mess around with the following code snippets to come up with a solution for your request.
    If none of these help, please post your code and I will gladly help you as best I can.

    to get an instance of the Tree you can do this in BLOCKED SCRIPT

    var tree = igtree_getTreeById("TREENAME");

    just replace "TREENAME" with the actual ID of your UltraWebTree.

    you'll also need the node that is selected.

    var node = tree.getSelectedNode();

    you'll want to check to see if this parent node has any child nodes...

    var childNodes = node.getChildNodes();

    if (node == null || childNodes .length == 0) {
            return;
    }

    if it does have child nodes then you'll want to loop through the child nodes and
    check the checkboxes.

    for (i = 0; i < childNodes.length; i++) {
         // Place checkbox code in here //
    }

     
    I hope this helps!

    -Tim