在项目里用ztree时遇到一个问题,只有最后一个根节点的子节点显示,其他的子节点都加载不出来!

jvquery 发布于 2018/01/09 12:21
阅读 1K+
收藏 0

@zTree 你好,在项目里用ztree时遇到一个问题,只有最后一个根节点的子节点显示,其他的子节点都加载不出来!想跟你请教个问题:jquery.min-2.1.4.js这是项目里的jquery版本!这个要怎么解决啊?

这是引入的js

这是代码

异步加载这样,在zTreeNodes=[]里写死节点数据也是这种效果!

加载中
0
默飞
默飞

把你的静态数据贴出来

jvquery
jvquery
静态数据? 你是说节点的数据吗?如果是……后台响应的节点数据肯定是没错的
0
李索锐

把写死的代码贴出来就好了,八成是

jvquery
jvquery
写死的代码贴出来了! 节点数据应该是没问题的,树加载出来之后我获取所以checked的节点id,都能获取到,而且层级关系也没错,就是显示不出来!
0
jvquery
jvquery

复制的官方的demo节点数据,效果一样的!

李索锐
你先给ID PID等属性加上双引号“ID“,还是不行你试一下run官方给的网页demo,还不行你换一个浏览器run
0
jvquery
jvquery

zList=[{"id":1,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":101,"name":"****","pid":1,"checked":"true"}
    ,{"id":102,"name":"****","pid":1,"checked":"true"}
    ,{"id":103,"name":"****","pid":1,"checked":"true"}
    ,{"id":104,"name":"****","pid":1,"checked":"true"}
    ,{"id":105,"name":"****","pid":1,"checked":"true"}
    ,{"id":106,"name":"****","pid":1,"checked":"true"}
    ,{"id":2,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":201,"name":"****","pid":2,"checked":"true"}
    ,{"id":202,"name":"****","pid":2,"checked":"true"}
    ,{"id":3,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":301,"name":"****","pid":3,"checked":"true"}
    ,{"id":4,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":401,"name":"****","pid":4,"checked":"true"}
    ,{"id":402,"name":"****","pid":4,"checked":"true"}
    ,{"id":403,"name":"****","pid":4,"checked":"true"}
    ,{"id":5,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":501,"name":"****","pid":5,"checked":"true"}
    ,{"id":502,"name":"****","pid":5,"checked":"true"}
    ,{"id":6,"name":"****","pid":0,"open":"true"}
    ,{"id":601,"name":"****","pid":6}
    ,{"id":602,"name":"****","pid":6}
    ,{"id":7,"name":"****","pid":0,"open":"true"}
    ,{"id":701,"name":"****","pid":7}
    ,{"id":702,"name":"****","pid":7}
    ,{"id":703,"name":"****","pid":7}
    ,{"id":704,"name":"****","pid":7}
    ,{"id":705,"name":"****","pid":7}
    ,{"id":8,"name":"****","pid":0,"open":"true"}
    ,{"id":801,"name":"****","pid":8}
    ,{"id":802,"name":"****","pid":8}
    ,{"id":803,"name":"****","pid":8}
    ,{"id":9,"name":"****","pid":0,"open":"true"}
    ,{"id":901,"name":"****","pid":9}
    ,{"id":902,"name":"****","pid":9}
    ,{"id":903,"name":"****","pid":9}
    ,{"id":10,"name":"****","pid":0,"open":"true"}
    ,{"id":1001,"name":"****","pid":10}
    ,{"id":1002,"name":"****","pid":10}
    ,{"id":11,"name":"****","pid":0,"open":"true"}
    ,{"id":1101,"name":"****","pid":11}
    ,{"id":1102,"name":"****","pid":11}]
这是后台响应的节点数据

0
默飞
默飞

引用来自“jvquery”的评论

zList=[{"id":1,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":101,"name":"****","pid":1,"checked":"true"}
    ,{"id":102,"name":"****","pid":1,"checked":"true"}
    ,{"id":103,"name":"****","pid":1,"checked":"true"}
    ,{"id":104,"name":"****","pid":1,"checked":"true"}
    ,{"id":105,"name":"****","pid":1,"checked":"true"}
    ,{"id":106,"name":"****","pid":1,"checked":"true"}
    ,{"id":2,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":201,"name":"****","pid":2,"checked":"true"}
    ,{"id":202,"name":"****","pid":2,"checked":"true"}
    ,{"id":3,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":301,"name":"****","pid":3,"checked":"true"}
    ,{"id":4,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":401,"name":"****","pid":4,"checked":"true"}
    ,{"id":402,"name":"****","pid":4,"checked":"true"}
    ,{"id":403,"name":"****","pid":4,"checked":"true"}
    ,{"id":5,"name":"****","pid":0,"open":"true","checked":"true"}
    ,{"id":501,"name":"****","pid":5,"checked":"true"}
    ,{"id":502,"name":"****","pid":5,"checked":"true"}
    ,{"id":6,"name":"****","pid":0,"open":"true"}
    ,{"id":601,"name":"****","pid":6}
    ,{"id":602,"name":"****","pid":6}
    ,{"id":7,"name":"****","pid":0,"open":"true"}
    ,{"id":701,"name":"****","pid":7}
    ,{"id":702,"name":"****","pid":7}
    ,{"id":703,"name":"****","pid":7}
    ,{"id":704,"name":"****","pid":7}
    ,{"id":705,"name":"****","pid":7}
    ,{"id":8,"name":"****","pid":0,"open":"true"}
    ,{"id":801,"name":"****","pid":8}
    ,{"id":802,"name":"****","pid":8}
    ,{"id":803,"name":"****","pid":8}
    ,{"id":9,"name":"****","pid":0,"open":"true"}
    ,{"id":901,"name":"****","pid":9}
    ,{"id":902,"name":"****","pid":9}
    ,{"id":903,"name":"****","pid":9}
    ,{"id":10,"name":"****","pid":0,"open":"true"}
    ,{"id":1001,"name":"****","pid":10}
    ,{"id":1002,"name":"****","pid":10}
    ,{"id":11,"name":"****","pid":0,"open":"true"}
    ,{"id":1101,"name":"****","pid":11}
    ,{"id":1102,"name":"****","pid":11}]
这是后台响应的节点数据

拿你的数据,放在ztree的demo  没毛病啊

jvquery
jvquery
是啊 这就是蛋疼的地方,把我的数据放在官方的demo里没问题,把官方demo的数据放在我的项目里有问题,这就肯定不是节点数据的问题了,可能是配置问题或js文件冲突之类的!但是这种问题不好找啊!头都要炸了
0
jvquery
jvquery

问题解决了,感觉是插件的一个bug,设置view.showLine=false;就可以正常显示了,但是这个属性是控制显示连接线的,所以说感觉是插件本身的一个bug。@zTree

zTree
zTree
你现在再把这个设置去掉,立刻就出现问题么?? 有点儿不可思议呀
返回顶部
顶部