-
17 Sep 2012 5:33 AM #1
Answered: How to select a record of a treepanel with the record id ?
Answered: How to select a record of a treepanel with the record id ?
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.getStore().getById(id) is undefined whereas the id is correct.PHP Code:treePanel.getSelectionModel().select(treePanel.getStore().getById(id));
-
Best Answer Posted by vietits
You should use getNodeById() instead of getById():
Code:treePanel.getSelectionModel().select(treePanel.getStore().getNodeById(id));
-
17 Sep 2012 5:44 AM #2
ID type
ID type
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
Try this.Code:treePanel.getSelectionModel().select(treePanel.getStore().getById(parseInt(id)));
-
17 Sep 2012 6:05 AM #3
I don't think this is the problem, because
PHP Code:id = record.data.fil_id
-
17 Sep 2012 11:46 PM #4
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.
-
18 Sep 2012 11:26 PM #5
-
19 Sep 2012 12:27 AM #6
You should use getNodeById() instead of getById():
Code:treePanel.getSelectionModel().select(treePanel.getStore().getNodeById(id));
-
19 Sep 2012 12:32 AM #7
That's working ! Thanks !
By the way do you know how can I open the treestore to the selected record?
EDIT: Get it :PHP Code:treePanel.expandPath(treePanel.getStore().getNodeById(record.data.fil_id).getPath());


Reply With Quote