var setting = {
view: {
selectedMulti: false
},
check: {
enable: true
//初始化树
function treeInt(){
$('#treeDemo').empty();
$.ajax({
type:"get",
// url:"/styles/js/mock_data/inspect/task_tree.json",
url:"/api/inspect/getTaskTree",
dataType:'json',
async:true,
success:function(response){
if(response.code==200){
var data = response.data;
function tree(m){
var nodes = [];
if(m.length !== 0){
$.each(data, function(i,v) {
var obj = {};
obj.name = v.displayName;
obj.t = v.fullName;
obj.open = true;
// obj.icon = "../../../css/zTreeStyle/img/diy/treeIcon.png";
if(v.subNodes !== null){
obj.children = [];
$.each(v.subNodes, function(a,b) {
var objOne = {};
objOne.name = b.displayName;
objOne.t = b.fullName;
objOne.open = true;
// objOne.icon = "../../../css/zTreeStyle/img/diy/treeIcon.png";
if(b.subNodes !== null){
objOne.children = [];
$.each(b.subNodes, function(z,l) {
var objTwo = {};
objTwo.name = l.displayName;
objTwo.t = l.fullName; //在这里构造数据时,加个 下面设置t字段 displayName它是显示用的,fullName它是传给后端的
objOne.children.push(objTwo);
});
}
obj.children.push(objOne);
});
nodes.push(obj);
} else {
obj.isParent = true;
nodes.push(obj);
}
});
return nodes;
}
}
// console.log(tree(data));
var setting = {
view: {
selectedMulti: false
},
check: {
enable: true
,chkStyle: 'checkbox'
,radioType: "level"
},
data: {
key: {
title: "t" //在这里设置关键的t字段
}
}
// data: {
// simpleData: {
// enable: true
// }
// },
// edit: {
// enable: true
// }
};
function setCheck() {
setting.check.chkStyle = $("#r1").attr("checked")? "checkbox":"checkbox";
setting.check.enable = (!$("#disablechk").attr("checked"));
$.fn.zTree.init($("#treeDemo"), setting, tree(data));
}
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, tree(data));
setCheck();
});
}
}
});
}
取的时候 var checkedList = $('#treeDemo>li>ul>li>ul>li>span[class~="checkbox_true_full"]');
$(checkedList[i]).next()[0].title
$('.strCount').fadeIn(42).html('您最多能输入64字符,现已超出'+beyond+'字符').fadeOut(2000)