1. #1
    Ext User
    Join Date
    Feb 2009
    Posts
    22
    Vote Rating
    0
    JensHeyer is on a distinguished road

      0  

    Default keep GridView row selection on row update event

    keep GridView row selection on row update event


    Hi everybody,

    I would like to know if there is a possibility to keep the focus on a selected row of a GridView. When updating an item in the ListStore the selection always gets lost.

    Jens

  2. #2
    Ext User
    Join Date
    Feb 2009
    Posts
    22
    Vote Rating
    0
    JensHeyer is on a distinguished road

      0  

    Default


    I tried to renew the focus after an Events.RowUpdate occurs but nothing happens. Here is the example code:

    Code:
    final GridView view = grid.getView();
    view.addListener(Events.RowUpdated, new Listener<GridEvent<ModelData>>() {
      public void handleEvent(GridEvent<ModelData> event) {
        view.focusRow(event.getRowIndex());
      }
    });
    Could this belong to the fact that focusEnabled is false after the Event is fired? This is an extract of the refreshRow method in the GridView class:

    Code:
    protected void refreshRow(int row) {
      ModelData m = ds.getAt(row);
      if (m != null) {
        // do not change focus on refresh
        // handles situation with changing cell value with field binding
        focusEnabled = false;
        insertRows(ds, row, row, true);
        getRow(row).setPropertyInt("rowIndex", row);
        onRemove(ds, m, row + 1, true);
        GridEvent<ModelData> e = new GridEvent<ModelData>(grid);
        e.setRowIndex(row);
        e.setModel(ds.getAt(row));
        fireEvent(Events.RowUpdated, e);
        focusEnabled = true;
      }
    }
    Any ideas to solve this problem?