zTree 显示为‘aa’,当选择aa时,传的参数为‘22’

荒凉一梦 提交于 2019-12-26 03:50:37

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)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!