How to programmatically update specific row in GWT CellTable

user358448 picture user358448 · Jun 1, 2011 · Viewed 7.6k times · Source

I have 5 rows in GWT CellTable. The table has 2 columns id, value. I have gwt timer which must periodically update value for specific id. So in timer implementation i call something like that:

....
double value = calcValueForId(id);
update(id, value);
.....
private void update(int id, double value) {
// here i have access to cell table instance and data provider (AsyncDataProvider)
// how to access row with given id and update its value column
}

Thanks.

Answer

Thomas Broyer picture Thomas Broyer · Jun 1, 2011

You have to retrieve the item (of the type you used to parameterize your CellTable) and then you can call updateRowData of your AsyncDataProvider (or setRowData on the CellTable) with the item's index. This will tell that the items (actually only one in your case) starting at the given index have changed, so the table must be redrawn (for now, the whole table will be refreshed, but a later version of GWT might add "per row" refresh).

In your particular case though (only 5 rows and 2 columns), maybe CellTable isn't the best fit…