PDA

View Full Version : Re-rendering individual grid cell



mattpainter
28 Jan 2010, 5:25 PM
Hi,

I have a Live Grid with many columns and a separate editing panel for the grid's fields.

I am successfully updating the grid's store with the model data from the edit panel, however I would like to re-render only the affected row in the grid and cannot determine how.

The Javadocs for Store indicate that the grid is automatically updated, however my code below doesn't appear to:

grid.getStore().update(model);I resorted to the rather nasty code to re-render the grid:


grid.getStore().fireEvent(ListStore.DataChanged, new StoreEvent<ItemGridModel>(grid.getStore()));however this resets the grid's horizontal scrolling. The grid has around 30 columns so this is not ideal. Ideally, I'd like for the user to be able to scroll to a position in the grid, edit the fields for the selected row, hit save and for the grid to not move.

Is there a simple re-render row event that can be fired? I've dug through the editable grid code in GXT for the closest equivalent and can't see anything obvious. I could try View.focusCell() but I suspect this will still make the grid jump.

Any pointers would be appreciated.

Thanks,
Matt

mattpainter
28 Jan 2010, 7:37 PM
Hi guys,

After many dead ends (not knowing anything about the inner workings of GXT grids) and laboriously step-debugging through rendering code, I fixed my issue by calling the rather obvious refreshRow().

My trap was that I was updating the Live Grid's store when a model was being updated, however I wasn't updating the display store so early attempts at calling refreshRow() were doing nowt.

M

Arno.Nyhm
29 Jan 2010, 12:24 PM
if you update a Record from the store then the grid view is also updated.

mattpainter
31 Jan 2010, 6:23 PM
Hi Arno,

Of course, you're right. I got side-tracked with the refreshRow() however I see now that my fundamental problem was that I wasn't updating the display store (this is a live grid, so there's two stores and I was only initially updating the non-display store).

I've removed the call to refreshRow() and all still works dandy.

Thanks,
M