zTree 显示为‘aa’,当选择aa时,传的参数为‘22’
Posted 教父123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zTree 显示为‘aa’,当选择aa时,传的参数为‘22’相关的知识,希望对你有一定的参考价值。
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)
以上是关于zTree 显示为‘aa’,当选择aa时,传的参数为‘22’的主要内容,如果未能解决你的问题,请参考以下文章