Dojo 树父节点
我想知道是否有人有办法获取道场树中项目的父节点?我已经尝试过,但似乎不起作用。
我尝试了几种不同的方法。
首先我尝试了这个:
this.tree.get("path")[this.tree.get("path").length - 2];
接下来我尝试了我在这个网站上找到的内容: http://dojo-toolkit.33424.n3.nabble.com/how-do-I-get-the-parent-node-of-a-dijit-Tree-node-td1788430.html< /a>\
似乎都不起作用。我不知道为什么这是一个如此复杂的事情,因为这可能是一个非常常见的操作。如果你能帮我解决这个问题那就太好了。
谢谢
编辑:我想更让我失望的是我首先尝试的方法(提供的代码示例)有时会起作用。所以这真的让我很困惑。
I was wondering if anyone had a way to get the parent node of an item in a dojo tree? I have tried but it doesn't seem to work.
I have tried a few different ways.
First I tried this:
this.tree.get("path")[this.tree.get("path").length - 2];
Next I tried what I found on this site: http://dojo-toolkit.33424.n3.nabble.com/how-do-I-get-the-parent-node-of-a-dijit-Tree-node-td1788430.html\
Neither one seems to work. I don't know why this is such a complicated thing when it is presumably a pretty common operation. If you could help me with this that would be awesome.
Thanks
EDIT: I guess what's throwing me off even more is that the method I tried first (the code sample provided) sometimes work. So this is really confusing me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Dojo v1.7,我使用了:
该代码已被重构,但我很确定它有效。需要注意的一些事情是 1) 我认为这仅在您正在查找的父项目需要是选定项目 (tree.selectedItems[0]) 时才有效,并且 2) 如果以下情况,此行可能不起作用您选择的项目是树的根(如果根被隐藏,则为顶级项目)。
Using Dojo v1.7, I have used:
That code has since been refactored away, but I'm pretty sure it worked. Some of the things to be aware of with this is 1) I think this only works if the item whose parent you are looking for needs to be a selected item (tree.selectedItems[0]) and 2) this line might not work if your selected item is the tree's root (or the top level item if the root is hidden).