extjs 4树通过其内部id(而不是通过记录索引)选择特定节点

发布于 2024-11-15 21:37:55 字数 394 浏览 7 评论 0原文

我正在尝试将数据视图(资源管理器窗口)与树(目录树)同步。 当我单击数据视图上的元素时,我希望在树上选择相同的节点

问题是使用 tree.getSelectionModel().select(index) 不允许我通过节点的内部 id(我在树存储中提供的 id)来选择节点,而只能通过记录索引来选择节点... 所以我无法同步两个视图...... 会有expandPath()的解决方案,但是我的树存储是由关系数据库(id,name,parent_id等)提供的,因此找到完整路径对服务器来说是(或可能是)一个沉重的负担(我希望避免必须提供任何路径...)。

基本上我希望能够说“展开“id =”(或树存储的任何其他键/值)的节点。

这可能吗?有任何解决方法吗?

感谢您阅读我的文章!

I'm trying to sync a dataview (explorer window) with a tree (directory tree).
When I click on an element on my dataview, I'd like the same node gets selected on the tree

The problem is that using the
tree.getSelectionModel().select(index)
doesn't allow me to select the node by its internal id (the id I provided in my treestore), but only by the record index...
So I just can't sync both views...
There would be the solution of the expandPath(), but my treestore is fed by a relational database (id,name,parent_id etc..), so finding the full path is(or could be) a heavy load for the server (I'd like to avoid to have to provide any path...).

Basically I would like to be able to say "expand the node where the "id= " (or any other key/value of the treestore).

Is it possible ? Is there any workaround ?

Thank you for reading me !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒解孤独 2024-11-22 21:37:55

tree.getSelectionModel().select(record) 函数可以接受记录实例而不是索引。我会做这样的事情:

var record = tree.getRootNode().findChild('id_name','record_id',true);
tree.getSelectionModel().select(record);

有关 findChild 函数的更多信息,请查看此处的 NodeInterface 文档:
http://docs.sencha .com/ext-js/4-0/#/api/Ext.data.NodeInterface-method-findChild

The tree.getSelectionModel().select(record) function can accept a record instance instead of an index. I would do something like this:

var record = tree.getRootNode().findChild('id_name','record_id',true);
tree.getSelectionModel().select(record);

for more info on the findChild function, check out the NodeInterface docs here:
http://docs.sencha.com/ext-js/4-0/#/api/Ext.data.NodeInterface-method-findChild

紧拥背影 2024-11-22 21:37:55

您还可以使用 selecteditemtree.data.id 来实现此目的。

you can also use selecteditemtree.data.id for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文