现在在ztree中,如果检查了任何子节点,那么它也检查了它的父节点,但是我不想检查它的父节点。有什么办法吗?
var setting = {
view: {
dblClickExpand: true,
selectedMulti: false,
showLine: false,
nameIsHTML: true,
},
check: {
enable: true,
},
data: {
simpleData: {
enable: true
}
},
};
答案 0 :(得分:1)
setting.check.chkboxType:
当一个节点被选中或未选中时,控制其父节点及其子节点自动选中或未选中。当[setting.check.enable = true&setting.check.chkStyle =“ checkbox”]
有效默认:{“ Y”:“ ps”,“ N”:“ ps”}
因此,我建议使用:
check: {
enable: true,
chkboxType: { "Y": "s", "N": "s" }
},
var setting = {
view: {
dblClickExpand: true,
selectedMulti: false,
showLine: false,
nameIsHTML: true,
},
check: {
enable: true,
chkboxType: { "Y": "s", "N": "s" }
},
data: {
simpleData: {
enable: true
}
}
};
var zTreeObj;
var zNodes = [
{name:"test1", open:true, children:[
{name:"test1_1"}, {name:"test1_2"}]},
{name:"test2", open:true, children:[
{name:"test2_1"}, {name:"test2_2"}]}
];
zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zTree/zTree_v3@master/css/demo.css" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/zTree/zTree_v3@master/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/zTree/zTree_v3@master/js/jquery.ztree.all.js"></script>
<div>
<ul id="treeDemo" class="ztree"></ul>
</div>