extjs 4树通过其内部id(而不是通过记录索引)选择特定节点
我正在尝试将数据视图(资源管理器窗口)与树(目录树)同步。 当我单击数据视图上的元素时,我希望在树上选择相同的节点
问题是使用 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 thetree.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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:
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
您还可以使用
selecteditemtree.data.id
来实现此目的。you can also use
selecteditemtree.data.id
for this.