Home >Web Front-end >HTML Tutorial >jquery ztree checkbox manually select the problem_html/css_WEB-ITnose
The checkbox of ztree must be selected by clicking on the small icon. Now I want to click on the actual content, and the checkbox is selected, as shown in the figure below. Click "Administrator", then the checkbox is selected, and I have also done the triggering event. The code is as follows, But still not selected.
Thank you all in advance
var setting = { check: { enable: true }, data: { simpleData: { enable: true } }, callback: { beforeClick: function (treeId, treeNode) { var zTree = $.fn.zTree.getZTreeObj("treeDemo"); if (treeNode.isParent) { //zTree.expandNode(treeNode); return false; } else { treeNode.checked = true; return true; } } } };
It seems not This function is great!
LZ! The research is out. Testing is OK! You try
function zTreeOnClick(event, treeId, treeNode) { var treeObj = $.fn.zTree.getZTreeObj("treeDemo"); var node = treeObj.getNodeByTId(treeNode.tId); treeObj.checkNode(node, true, true);} var setting = { check: { enable: true }, data: { simpleData: { enable: true } }, callback: { onClick: zTreeOnClick } };
LZ! The research is out. Testing is OK! You try
function zTreeOnClick(event, treeId, treeNode) { var treeObj = $.fn.zTree.getZTreeObj("treeDemo"); var node = treeObj.getNodeByTId(treeNode.tId); treeObj.checkNode(node, true, true);} var setting = { check: { enable: true }, data: { simpleData: { enable: true } }, callback: { onClick: zTreeOnClick } };
Tid is automatically generated! In the same way, you can also use the ID as a parameter to find the node! There are several ways to get nodes, you can try
LZ! Researched it. Testing is OK! You try
function zTreeOnClick(event, treeId, treeNode) { var treeObj = $.fn.zTree.getZTreeObj("treeDemo"); var node = treeObj.getNodeByTId(treeNode.tId); treeObj.checkNode(node, true, true);} var setting = { check: { enable: true }, data: { simpleData: { enable: true } }, callback: { onClick: zTreeOnClick } };