updating a single cell

105 views
Skip to first unread message

Matthew Pocock

unread,
Aug 16, 2012, 8:10:34 AM8/16/12
to google-we...@googlegroups.com
Hi,

I'm using DataGrid with some grids that get quite large. Individual cell values alter independently of each other due to events coming into the application over comet. At the moment, to display the new value I have to call table.redraw(). This is very inefficient when the table has a lot of columns - there can be a delay of several seconds while the whole table is rendered. Is it possible to tell a datagrid that a particular cell needs redrawing?

Thanks,

Matthew

--
Dr Matthew Pocock
Integrative Bioinformatics Group, School of Computing Science, Newcastle University
skype: matthew.pocock
tel: (0191) 2566550

ssamara

unread,
Aug 16, 2012, 11:22:51 AM8/16/12
to google-we...@googlegroups.com
Not sure if you can re-render cells in isolation, but you should be able to get it to redraw individual rows rather than the whole table. Try replacing the updated item with itself in the DataProvider (e.g. if using a ListDataProvider by calling set(index, item) on the underlying List, or if using an AsyncDataProvider by calling updateRowData on the dataprovider passing in a singleton list containing just the updated item). Alternatively you can try calling setRowData() on the DataGrid itself.

Thomas Broyer

unread,
Aug 16, 2012, 12:42:41 PM8/16/12
to google-we...@googlegroups.com


On Thursday, August 16, 2012 5:22:51 PM UTC+2, ssamara wrote:
Not sure if you can re-render cells in isolation, but you should be able to get it to redraw individual rows rather than the whole table. Try replacing the updated item with itself in the DataProvider (e.g. if using a ListDataProvider by calling set(index, item) on the underlying List, or if using an AsyncDataProvider by calling updateRowData on the dataprovider passing in a singleton list containing just the updated item). Alternatively you can try calling setRowData() on the DataGrid itself.

…or use redrawRow()

ssamara

unread,
Aug 16, 2012, 1:05:08 PM8/16/12
to google-we...@googlegroups.com
Aha! I knew there had to be a simpler way so this is good to know. Thanks.

On Thursday, 16 August 2012 17:42:41 UTC+1, Thomas Broyer wrote:

…or use redrawRow()

Matthew Pocock

unread,
Aug 21, 2012, 7:45:47 PM8/21/12
to google-we...@googlegroups.com
Hum, I can't see redrawRow on DataGrid. I'm on 2.4 - perhaps it's in a different release? My data is exposed through AsyncDataProvider. I'm currently using this monstrosity to update rows, but I'm not entirely confident that it's right or particularly sane.

int i = table.getVisibleItems().indexOf(instance);
if(i >= 0) {
  table.setRowData(table.getPageStart() + i, Arrays.asList(instance));
}

Matthew

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/PY4q3fgoPNsJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Thomas Broyer

unread,
Aug 22, 2012, 4:10:00 AM8/22/12
to google-we...@googlegroups.com


On Wednesday, August 22, 2012 1:45:47 AM UTC+2, Matthew Pocock wrote:
Hum, I can't see redrawRow on DataGrid. I'm on 2.4 - perhaps it's in a different release?

Ah, yes, it's new in 2.5.0-rc1)
 
My data is exposed through AsyncDataProvider. I'm currently using this monstrosity to update rows, but I'm not entirely confident that it's right or particularly sane.

int i = table.getVisibleItems().indexOf(instance);
if(i >= 0) {
  table.setRowData(table.getPageStart() + i, Arrays.asList(instance));
}

I've been using a similar trick for a CellTree, and I must say I'm not comfortable with it either. But it works, with few reasons to break in a future release (unless some kind of optimization is added to avoid redrawing a row if the object is the same, but it would break a lot of people's code so it has little to no chance to happen in practice)
Reply all
Reply to author
Forward
0 new messages