Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all the children nodes from the selected node in jstree

var selectedNode = $("#evts").jstree("get_selected");

Hi everyone.. I am using the above code to get the selected node from the tree. How to get all the children nodes for the selectedNode...I am using jstree 3.3...

Thanks in advance!

like image 369
user3401747 Avatar asked Mar 28 '16 14:03

user3401747


2 Answers

var currentNode = $("#evts").jstree("get_selected");
   var childrens = $("#evts").jstree("get_children_dom",currentNode);

   for(var i=0;i<childrens.length;i++)
   {
   alert(childrens[i].innerText);
   }

the above code works as expected...

like image 99
user3401747 Avatar answered Oct 05 '22 06:10

user3401747


 var selectedNode = $("#evts").jstree("get_selected");
 var node_info=$('#evts').jstree("get_node",selectedNode[0]);

 // this node_info contains **children_d** an array of all child nodes' id .
 // **parents** an array of parent nodes


    alert(node_info.children_d.join(','));
    alert(node_info.parents.join(','));
like image 31
Joshy Francis Avatar answered Oct 05 '22 08:10

Joshy Francis