1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    France
    Posts
    159
    Answers
    2
    Vote Rating
    3
    Elfayer is on a distinguished road

      0  

    Default 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):
    PHP Code:
    treePanel.getSelectionModel().select(treePanel.getStore().getById(id)); 
    treePanel.getStore().getById(id) is undefined whereas the id is correct.

  2. You should use getNodeById() instead of getById():
    Code:
    treePanel.getSelectionModel().select(treePanel.getStore().getNodeById(id));

  3. #2
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    136
    Answers
    2
    Vote Rating
    3
    harman is on a distinguished road

      0  

    Default 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

    Code:
    treePanel.getSelectionModel().select(treePanel.getStore().getById(parseInt(id))); 
    Try this.

  4. #3
    Sencha User
    Join Date
    Jul 2012
    Location
    France
    Posts
    159
    Answers
    2
    Vote Rating
    3
    Elfayer is on a distinguished road

      0  

    Default


    I don't think this is the problem, because
    PHP Code:
    id record.data.fil_id 

  5. #4
    Sencha User
    Join Date
    Jul 2012
    Location
    France
    Posts
    159
    Answers
    2
    Vote Rating
    3
    Elfayer is on a distinguished road

      0  

    Default


    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.

  6. #5
    Sencha User
    Join Date
    Jul 2012
    Location
    France
    Posts
    159
    Answers
    2
    Vote Rating
    3
    Elfayer is on a distinguished road

      0  

    Default


    UP

  7. #6
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      1  

    Default


    You should use getNodeById() instead of getById():
    Code:
    treePanel.getSelectionModel().select(treePanel.getStore().getNodeById(id));

  8. #7
    Sencha User
    Join Date
    Jul 2012
    Location
    France
    Posts
    159
    Answers
    2
    Vote Rating
    3
    Elfayer is on a distinguished road

      0  

    Default


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

Thread Participants: 2