View Full Version : How to select a record of a treepanel with the record id ?
Elfayer
17 Sep 2012, 5:33 AM
Hi,
I would like to select a record of a tree panel with the record id. Is it possible?
I have that (doesn't work):
treePanel.getSelectionModel().select(treePanel.getStore().getById(id));
treePanel.getStore().getById(id) is undefined whereas the id is correct.
harman
17 Sep 2012, 5:44 AM
Is that the String ID that you are passing it?
If so you need to change it to number as it expects a number in place of Id
treePanel.getSelectionModel().select(treePanel.getStore().getById(parseInt(id)));
Try this.
Elfayer
17 Sep 2012, 6:05 AM
I don't think this is the problem, because
id = record.data.fil_id
Elfayer
17 Sep 2012, 11:46 PM
The problem persist. I've read several things in the docs, but there is not much methods that returns a model. I say model, because the select method either take a model or an index. And I don't want an index because the tree is supposed to be closed, and open itself to the concerned directory.
Elfayer
18 Sep 2012, 11:26 PM
UP
vietits
19 Sep 2012, 12:27 AM
You should use getNodeById() instead of getById():
treePanel.getSelectionModel().select(treePanel.getStore().getNodeById(id));
Elfayer
19 Sep 2012, 12:32 AM
That's working ! Thanks !
By the way do you know how can I open the treestore to the selected record?
EDIT: Get it :
treePanel.expandPath(treePanel.getStore().getNodeById(record.data.fil_id).getPath());
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.