Home >Web Front-end >HTML Tutorial >jquery ztree checkbox manually select the problem_html/css_WEB-ITnose

jquery ztree checkbox manually select the problem_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:01:071260browse

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;                }            }        }    };


Reply to the discussion (solution)

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	}		};


I tried this. First of all, there is no tId attribute in node, and an error "'null' is empty or not an object" will be reported. There is only the id attribute. I will Even if tId is changed to id, this error will still be reported. Is there something wrong with me? ? ?

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	}		};


This works
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn