@zTree 你好,想跟你请教个问题:
首先ztree配置:
setting = {
view: {
showLine: false
},
check: {
enable: true,
chkboxType:{ "Y" : "ps", "N" : "s" } // 被勾选时关联父和子 ; 取消勾选时,不勾选父节点
},
data: {
simpleData: {
enable: true,
idKey:"id",
pIdKey:"parentId",
rootPid:-1
}
}
};
getNodeByTId 这个方法感觉有问题,
当后台取得tree数据
[{"id":1,"parentId":-1,"name":"系统管理","open":true},{"id":2,"parentId":1,"name":"用户管理"},{"id":3,"parentId":2,"name":"新增用户"},{"id":4,"parentId":2,"name":"编辑用户"},{"id":5,"parentId":2,"name":"删除用户"},{"id":6,"parentId":1,"name":"角色管理"},{"id":7,"parentId":6,"name":"新增角色"},{"id":8,"parentId":6,"name":"删除角色"},{"id":9,"parentId":6,"name":"配置用户"},{"id":10,"parentId":6,"name":"配置权限"},{"id":11,"parentId":1,"name":"权限管理"},{"id":12,"parentId":-1,"name":"枚举类型管理","open":true},{"id":13,"parentId":12,"name":"枚举类型管理"},{"id":14,"parentId":13,"name":"新增枚举类型"},{"id":15,"parentId":13,"name":"修改枚举类型"},{"id":16,"parentId":13,"name":"删除枚举类型"},{"id":17,"parentId":-1,"name":"元件分类管理","open":true},{"id":18,"parentId":17,"name":"元件分类管理"},{"id":19,"parentId":18,"name":"新增特有属性"},{"id":20,"parentId":18,"name":"编辑特有属性"},{"id":21,"parentId":18,"name":"删除特有属性"},{"id":22,"parentId":-1,"name":"元件管理","open":true},{"id":23,"parentId":22,"name":"元件管理"},{"id":24,"parentId":23,"name":"元件导入"},{"id":25,"parentId":23,"name":"元件导出"},{"id":501,"parentId":-1,"name":"流程管理","open":true},{"id":502,"parentId":501,"name":"元件申请流程"},{"id":503,"parentId":502,"name":"新建元件申请流程"},{"id":504,"parentId":501,"name":"接插件申请流程"},{"id":505,"parentId":504,"name":"新建设备接插件申请流程"},{"id":506,"parentId":501,"name":"元件更改流程"},{"id":507,"parentId":506,"name":"新建元件更改流程"},{"id":508,"parentId":501,"name":"设备接插件更改流程"},{"id":509,"parentId":508,"name":"新建设备接插件更改流程"},{"id":510,"parentId":501,"name":"流程审批"},{"id":511,"parentId":510,"name":"元件审批"},{"id":512,"parentId":510,"name":"设备接插件审批"},{"id":513,"parentId":510,"name":"元件更改审批"},{"id":514,"parentId":510,"name":"设备接插件更改审批"},{"id":601,"parentId":-1,"name":"版本管理","open":true},{"id":602,"parentId":601,"name":"元件版本管理"},{"id":603,"parentId":602,"name":"删除元件版本"},{"id":604,"parentId":601,"name":"设备接插件版本管理"},{"id":605,"parentId":604,"name":"删除设备接插件版本"},{"id":701,"parentId":0,"name":"保存列"}]上面的数据id并非连续 id从25 下一个不是26而是501
当调用getNodeByTId 如:zTree.getNodeByTId("501")取得为null;
所以zTree.checkNode(node,。。。)报错
而如果id是连续的不报错 , 这是为什么 求解? 是我代码问题还是?
tid应该是ztree自己设的id,不是你数据里的id
规则大概是树的名称+"_"+你给的id,例如“tree_501”
回复 @works:的确不大!公公就是牛逼这个可行看来getNodeByTId这个方法价值不大回复 @494000376:用getNodeByParam("id","501");试了不行因为他是异步加载树节点的!
我认为你取出来的数据是他已经渲染过的,就是说,如果父节点没有展开过,那么应该是拿不到子节点的内容的
@494000376嘎!那就不知道了已经展开了这个方法就是个垃圾鸡肋方法,TId根本没办法知道。版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。