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
1115
How I can get all nodes from WebDataTree by js?
posted
getNodes Returns the collection of root nodes for the datatree.  
selectedNodes Returns an array holding all selected nodes.  
checkedNodes Returns an array holding all checked nodes.  

But I need to get all nodes from WebDataTree by js

How I can get all nodes from WebDataTree by js?

Parents
No Data
Reply
  • 17590
    Offline posted

    Hello Anton Pridanov,

    Thank you for posting in the community!

    The count of all  nodes in WebDataTree should be accesible by iterating through all the parent nodes and taking their children, for instance:

    function loopThroughNodes() {

      var tree = $find("<%= webdatatree1="" clientid="">");

     for(var i = 0; i < tree.getNodes().get_length(); i++) {

        var rootNode = tree.getNodes().getNode(i);

        recursiveIteration(rootNode);

      }

    }

    function recursiveIteration(node) {

      console.log(node.get_text());

    if(node.hasChildren()) {

      for(var j = 0; j < node.getItems.get_lenght(); j++) {

        var child = node.getItems().getNode(j);

        recursiveIteration(child);

          }

       }

    }

     

    I am also attaching a sample for your scenario using version 12.2.20122.2031 for you.

    Do not hesitate to contact me if you need any further support.

     Edit:Code Review

     

     

    WebDataTreeGetNodes.zip
Children