Ztree.getselectednodes () [0] is the first node to get the selected
Getnodebytid
overview [dependent Jquery.ztree.core core JS]
Quickly get a node JSON data object based on Ztree unique identification tId
Through the internal cache acquisition, do not need to traverse the node.
Please execute this method through the Ztree object.
Function parameter Description
Tidstring
Unique identification of the node within the Ztree tId
return value JSON
TId the corresponding node JSON data object
Null if no result is returned
function examples
1. Get the node data for tId = "Tree_10"
The code is as follows |
Copy Code |
var treeobj = $.fn.ztree.getztreeobj ("tree"); var node = Treeobj.getnodebytid ("tree_10"); Get the first one is: var node = Treeobj.getnodebytid ("Tree_1"); |
Gets all child node IDs under the current node
The code is as follows |
Copy Code |
var setting = { Data: { Simpledata: { enable:true } }, View: { Showicon:false p>}, callback:{ Onclick:function ztreeonclick (event, Treeid, TreeNode) { Alert (Treenode.tid + "," + Treenode.name+ "," +treeid); Var ids=[]; Ids=getchildren (Ids,treenode); } }, Check: { Enable:true, Autochecktrigger:false, chkboxtype:{"Y": "PS", "N": "PS"} } }; //ids is an array that returns an array of results TreeNode is the selected node Function GetChildren (ids,treenode) { Ids.push (treenode.id); if (treenode.isparent) { for (Var obj in Treenode.children) { GetChildren (ids,treenode.children[ OBJ]); } } return IDs; } |