Ztree gets the selected node, and ztree gets the node
$ (Document ). ready (function () {$. fn. zTree. init ($ ("# treeDemo"), setting, zNodes) ;}); function onCheck (e, treeId, treeNode) {var treeObj = $. fn. zTree. getZTreeObj ("treeDemo"), nodes = treeObj. getCheckedNodes (true), v = ""; for (var I = 0; I <nodes. length; I ++) {v + = nodes [I]. name + ","; alert (nodes [I]. id); // obtain the value of the selected node }}
How does ztree obtain node objects? Urgent
Var setting = {
Data :{
SimpleData :{
Enable: true
}
},
Callback :{
OnClick: onClick
}
};
Function onClick (event, treeId, treeNode, clickFlag ){
Alert (treeNode. tId + "," + treeNode. name); // click it to return the Node object treeNode.
Var zTree = $. fn. zTree. getZTreeObj ("treeDemo ");
// Var nodes = zTree. getNodes ();
Var nodes = zTree. getSelectedNodes ();
Alert (nodes [0]. name); // returns the object of the selected node
};
Upload an id from the background. It is best to specify a node in the ztree as the selected node,
1. The getNodeByParam method can locate the specified node data.
2. The selectNode method can be used to select a node. If you select the checkbox option, use the checkNode method.