PDA

View Full Version : keep GridView row selection on row update event



JensHeyer
26 May 2009, 12:46 AM
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

JensHeyer
26 May 2009, 1:55 AM
I tried to renew the focus after an Events.RowUpdate occurs but nothing happens. Here is the example 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:



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?