Results 1 to 2 of 2

Thread: Find and focus on a row in TreeGrid

  1. #1
    Sencha User
    Join Date
    Aug 2009
    Vote Rating

    Default Find and focus on a row in TreeGrid

    Given a TreeModel, I want to focus on the row that represents the model in TreeGrid.

    Normally with regular Grid, I do

    int index = grid.getStore().indexOf(m);
    For TreeGrid, I changed to

    int index = grid.getTreeStore().indexOf(m);
    But indexOf returns the index in parent, not the index in grid so the focus is off.

    How do I get the row index in grid? Or how do I get view to focus on a model?

  2. #2
    Sencha User WesleyMoy's Avatar
    Join Date
    Oct 2009
    Redwood City, California
    Vote Rating


    What you're trying to do would be most easily handled by getting the ListStore (not the TreeGridStore) from the TreeGrid and using that to find the index of your model object. You can get the ListStore by calling getStore on TreeGrid. This lets you determine exactly what the row index of the item is using indexOf. At this point, you can focus the appropriate row.

    The reason you should be using the ListStore is that this store represents the rows that will actually be displayed, in the order they would be shown. Any nodes that have been hidden because of filtering or collapsed parent nodes will correctly not take up any space. (These nodes themselves are not in the store and will have an index of -1.)

    There are a few things to keep in mind if you take this approach. First, the Grid must already have finished rendering. Second, any operation you may be responding to (like expanding, drag and drop, etc.) could result in a change in the index of the item you're interested in.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts