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
447
How can I create nodes with multiple levels down in webdatatree using javascript.
posted

I need to create multiple node levels down in WebDataTree on client side using javascript.

Here is what I need:

->Parent 1

   -> Child1

       -->Child 2

           ---> Child4

Here is the code I use:

for (var i = 0; i < 5; i++) {
 
               
        child_node = wdtTREE.createNode("Child1");
        if (i==0) {
            parent_node.getItems().add(child_node);
        }
	parent_node.Expanded = true;
	parent_node.Selected = true;
	child_node.ExpandAnscestors();
	parent_node = child_node; 

}

When I use this code, It is creating the first node under Parent. After that in the loop when i=2, it cannot add and I'm getting this error.

0x800a138f - JavaScript runtime error: Unable to get property 'add' of undefined or null reference

Please assist.