首页 新闻 搜索 专区 学院

zTree从后台加载数据无限循环

0
悬赏园豆:20 [已关闭问题] 关闭于 2016-01-23 14:44
 1  var setting = {  
 2                 data: {  
 3                     simpleData: {  
 4                         enable: true  
 5                     }  
 6                 } ,
 7                 async: {
 8                     enable: true,
 9                     url:"houtai/menuControl/queryMenu.html",
10                     autoParam:["id", "name", "level"],
11                     otherParam:{"otherParam":"zTreeAsyncTest"},
12                     dataFilter: filter
13                 }
14         };  
15         function filter(treeId, parentNode, childNodes) {
16             if (!childNodes) return null;
17             for (var i=0, l=childNodes.length; i<l; i++) {
18                 childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
19             }
20             return childNodes;
21         }
22         /*var zNodes =[  
23             { id:1, pId:0, name:"parentNode 1"},  
24             { id:11, pId:1, name:"parentNode 11"},  
25             { id:111, pId:11, name:"leafNode 111"},  
26             { id:112, pId:11, name:"leafNode 112"},  
27             { id:12, pId:1, name:"parentNode 12"},  
28             { id:121, pId:12, name:"leafNode 121"}, 
29             { id:13, pId:1, name:"parentNode 13"},  
30             { id:2, pId:0, name:"parentNode 2"}  
31         ];  */
32   
33         $(document).ready(function(){  
34             $.fn.zTree.init($("#treeDemo"), setting);  
35         });  

后台json格式:[{"pId":"0","id":"1","name":"小区介绍","isParent":true},{"pId":"2","id":"10","name":"二手货品交易","isParent":true},{"pId":"2","id":"11","name":"二手货品类型","isParent":true},{"pId":"2","id":"12","name":"出租信息","isParent":true},{"pId":"2","id":"13","name":"出租类型","isParent":true},{"pId":"3","id":"14","name":"小区问题","isParent":true},{"pId":"3","id":"15","name":"问题评论","isParent":true},{"pId":"3","id":"16","name":"问题类型","isParent":true},{"pId":"4","id":"17","name":"用户信息","isParent":true},{"pId":"5","id":"18","name":"活动信息","isParent":true},{"pId":"5","id":"19","name":"活动审核通知","isParent":true},{"pId":"0","id":"2","name":"生活服务","isParent":true},{"pId":"5","id":"20","name":"活动报名通知","isParent":true},{"pId":"5","id":"21","name":"活动取消通知","isParent":true},{"pId":"6","id":"22","name":"角色信息","isParent":true},{"pId":"6","id":"23","name":"用户角色信息","isParent":true},{"pId":"6","id":"24","name":"菜单信息","isParent":true},{"pId":"6","id":"25","name":"角色菜单信息","isParent":true},{"pId":"0","id":"3","name":"小区问答","isParent":true},{"pId":"0","id":"4","name":"用户管理","isParent":true},{"pId":"0","id":"5","name":"活动管理","isParent":true},{"pId":"0","id":"6","name":"权限管理","isParent":true},{"pId":"1","id":"7","name":"小区基本信息","isParent":true},{"pId":"1","id":"8","name":"小区公告","isParent":true},{"pId":"2","id":"9","name":"二手货品信息","isParent":true}]

醉丶心的主页 醉丶心 | 初学一级 | 园豆:135
提问于:2016-01-23 14:19
< >
分享
所有回答(1)
0

原来是我的json数据中isParent一直为true,纠结好久。

醉丶心 | 园豆:135 (初学一级) | 2016-01-23 14:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册