单击父节点时检查树的子节点 [ExtJS]
我想知道如何在单击 ExtJs 中的特定节点时检查树的同级节点。
我已经给了每个节点的 id,我可以访问单击的节点的 id。那么我如何继续自动检查子节点?
有人请帮助我..
I would like to know how can i check the sibling nodes of a tree while clicking on a particular node in ExtJs.
I had given id's for each node and i can access the id of a clicked node. then how can i proceed to checking the child nodes automatically ??
somebody please help me..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您希望它适用于当前节点的整个子树,则必须执行一些递归。
更集成一点:
If you want this to work on the whole subtree of the current node, you'll have to do some recursion.
A little more integrated:
它对我来说效果很好;)
It works well for me ;)
听众:{
}
listeners:{
}
C先生的答案很好(ExtJS 4.2),但是当父节点的子节点有1个子节点时会出现错误。这是我的一点改进。有人可以进一步改进
The answer of Mr C works fine(ExtJS 4.2), but a bug will occur when the childnodes of parentnode has 1 child. Here is my a little improvement. Someone can improve further
当您填充节点时,JSON 或 XML 需要将“checked”属性设置为 true 或 false。我假设您正在使用 AsyncTreeNode 来为您执行此操作。如果在没有此选中属性的情况下创建树节点,ExtJS 将不会使用该复选框来呈现它。
The JSON or XML will need the "checked" property set to true or false when you populate the nodes. I am assuming that you are using an AsyncTreeNode to do this for you. If the tree nodes are created without this checked property present, ExtJS will not render it with the checkbox.
或者,如果像我一样,您需要在选中/取消选中所有子叶节点时自动选中/取消选中父节点,您可以尝试以下操作:
Or, if like me, you need to automatically check/uncheck the parent node when all child leaf nodes are checked/unchecked you can try this: