Skip to content Skip to sidebar Skip to footer

How To Get Path Of Children When Parent Is Selected In Jstree

I'm trying to get the path of the parent and children nodes when the parent is selected. To get the path of the node selected I did the following: $('#jstree_demo_div').jstree({

Solution 1:

data.node.childrenreturns an array, which you can access by index. To get the i-th element use data.node.children[i]. For example, to iterate over all children of data.nodedo this:

for (var i =0; i < data.node.children.length; i++) {
  //for example call get_path of the childvar path = $(\'#jstree_demo_div\').jstree(true).get_path(data.node.children[i],"/");
}

I hope I understood you right and that is what you are looking for.

EDIT: You can use children_d to get all children of the node. Even the children of the children.

for (var i =0; i < data.node.children_d.length; i++) {
  //for example call get_path of the childvar path = $(\'#jstree_demo_div\').jstree(true).get_path(data.node.children_d[i],"/");
}

Hope I got you right this time. Just let me know if not.

Post a Comment for "How To Get Path Of Children When Parent Is Selected In Jstree"