extjs 4 tree select a specific node by its internal id (not by record index)
Asked Answered
G

2

5

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 !

Goldfarb answered 16/6, 2011 at 14:34 Comment(0)
W
9

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

Woodcraft answered 18/7, 2011 at 13:42 Comment(0)
R
0

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

Rescissory answered 20/8, 2013 at 12:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.