最近在尝试使用异步加载的ztree做一个菜单,但是第一级菜单加载完成之后显示在前端时,节点前没有加号。。这样我就没法加载下一级节点了。。请问我是哪里少写了什么吗?
var setting = {
view: {
//dblClickExpand: false,
showIcon: false,
expandSpeed: 100 //设置树展开的动画速度
},
//获取json数据
async: {
enable: true,
type:"post",
url: appUrl + "report/getTreeView.do", // Ajax 获取数据的 URL 地址
autoParam: ["treeId", "treeName"] //ajax提交的时候,传的是id值
},
data: {// 必须使用data
key : {
name : "treeName"
},
simpleData: {
enable: true,
idKey: "treeId", // id编号命名
pIdKey: "pId", // 父id编号命名
rootPId: 0
}
},
// 回调函数
//?????treeId
callback: {
onClick: function (event, treeId, treeNode, clickFlag) {
if (true) {
// alert(" 节点id是:" + treeNode.treeId + ", 节点文本是:" + treeNode.treeName);
}
},
//捕获异步加载出现异常错误的事件回调函数 和 成功的回调函数
onAsyncSuccess: function (event, treeId, treeNode, msg) {
}
}
};
$('#menuContent2').modal('show');
$.fn.zTree.init($("#tree"), setting);
var setting = {
view: {
//dblClickExpand: false,
showIcon: false,
expandSpeed: 100 //设置树展开的动画速度
},
//获取json数据
async: {
enable: true,
type:"post",
url: appUrl + "report/getTreeView.do", // Ajax 获取数据的 URL 地址
autoParam: ["treeId", "treeName"] //ajax提交的时候,传的是id值
},
data: {// 必须使用data
key : {
name : "treeName"
},
simpleData: {
enable: true,
idKey: "treeId", // id编号命名
pIdKey: "pId", // 父id编号命名
rootPId: 0
}
},
// 回调函数
//?????treeId
callback: {
onClick: function (event, treeId, treeNode, clickFlag) {
if (true) {
// alert(" 节点id是:" + treeNode.treeId + ", 节点文本是:" + treeNode.treeName);
}
},
//捕获异步加载出现异常错误的事件回调函数 和 成功的回调函数
onAsyncSuccess: function (event, treeId, treeNode, msg) {
}
}
};
$('#menuContent2').modal('show');
$.fn.zTree.init($("#tree"), setting);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货