1 var ids=[]; 2 Ids=getchildren (IDs, TreeNode); // TreeNode is the selected node, IDS is a child node ID array, format: 123,223,4,55
1. Get the ID of the direct child node
// The return value contains the ID of the selected node, which is ids[0] function GetChildren (IDs, TreeNode) { ids.push (treenode.id); //Select node ID, which is the parent node ID if (treenode.isparent) { for (var in treenode.children) { GetChildren (IDs, Treenode.children[obj]); } } return IDs;}
2. Get all child node IDs
1 //whether the return value contains the selected Node ID, depending on the situation2 function GetChildren (IDs, TreeNode) {3Ids.push (treenode.id);//Select the node ID, which is the parent node ID4 if(treenode.isparent) {5 for(varObjinchTreenode.children) {6 Ids.push (treenode.children[obj].id);7 }8 }9 returnIDs;Ten}
Ztree Getting child nodes