extjs 4树通过其内部ID(而非记录索引)选择特定节点 [英] extjs 4 tree select a specific node by its internal id (not by record index)

查看:182
本文介绍了extjs 4树通过其内部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

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

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...).

基本上,我想说的是扩展"id ="(或树存储的任何其他键/值)所在的节点.

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 ?

感谢您阅读我!

推荐答案

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

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);

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

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

这篇关于extjs 4树通过其内部ID(而非记录索引)选择特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆