Ztree gets the selected node, and ztree gets the node

Source: Internet
Author: User

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.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.