ztree 异步加载 点击展开出现undefined
点击boot展开
在console打印的是:
是index.html的内容
数据格式:
{
id":"0-null-0-/",
"name":"本地磁盘文件",
"absoluteName":"/",
"level":0,
"type":0,
"parentId":null,
"host":null,
"isParent":null,
"children":[{"id":"bin/","name":"bin/","absoluteName":"/bin/","level":1,"type":0,"parentId":"","host":null,"isParent":false,"children":null},
{"id":"boot/","name":"boot/","absoluteName":"/boot/","level":1,"type":0,"parentId":"","host":null,"isParent":true,"children":null},
{"id":"data1/","name":"data1/","absoluteName":"/data1/","level":1,"type":0,"parentId":"","host":null,"isParent":false,"children":null},
]
}
var tree = {
zTree:'',
pNode:'',
setting : {
showLine : true, //是否显示节点间的连线
check: {
enable: true,
autoCheckTrigger: true
},
async:{
enable: true, //采用异步加载
},
root:{
isRoot:true,
nodes:[]
},
data: {
key: {
name: "name"
},
simpleData: {
enable: true
}
},
callback: {
// beforeClick: zTreeBeforeClick,
// onClick: zTreeOnClick,
beforeClick: beforeExpand,
onAsyncSuccess: onAsyncSuccess,
onAsyncError: onAsyncError,
onCheck: onCheck
}
}
};
function onAsyncSuccess(event, treeId, treeNode, msg) {
if (!msg || msg.length == 0) {
return;
}
var zTree = $.fn.zTree.getZTreeObj("tree"),
totalCount = treeNode.count;
var parameter= {
parentId:treeNode.id,
level: treeNode.level,
host: treeNode.host,
type: treeNode.type,
name: treeNode.name,
absoluteName: treeNode.absoluteName
};
//获取parentId = id的数据,也就是子节点的id等于父节点的id,说明此父节点加载了子节点
if(!zTree.getNodeByParam("parentId",treeNode.id)){
BackupService.getDataSource(parameter).then(function(result){
/**
* 把查询出来的字节点追加到父节点上
*/
var tempData = [];
if(result.data.data.children.length>0) {
zTree.addNodes(treeNode,result.data.data.children,true);
var nodeTrees = treeNode.children;
for(var j=0,len1=nodeSource.length;j<len1;j++){
for(var i=0,len=nodeTrees.length;i<len;i++) {
if(nodeTrees[i].bsoluteName===nodeSource[j]){
nodeTrees[i].checked = true;
}
}
}
} else {
return;
};
}, function(msg){
console.log(msg);
});
}
}
求原因
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
?没看到数据呀