Catch-22 with Celltable and AsyncDataProvider

90 views
Skip to first unread message

Mike Dee

unread,
May 5, 2012, 11:43:42 AM5/5/12
to google-we...@googlegroups.com
According to the Celltable Developers Guide here:


The example given for AsyncDataProvider seems to have a flaw here when setting the row count.

// Add the columns.
table.addColumn(nameColumn, "Name");
table.addColumn(addressColumn, "Address");

// Set the total row count. You might send an RPC request to determine the total row count.
table.setRowCount(CONTACTS.size(), true); 

// Set the range to display. In this case, our visible range is smaller than the data set.
table.setVisibleRange(0, 3);

As the comment suggests, an RPC call would likely be necessary and it would likely be asynchronous.

That leaves the question, how does one know that the RPC call will return with the size by the time it is needed/used later on?  Should method wait until the value is returned?

törzsmókus

unread,
Oct 29, 2012, 3:52:44 PM10/29/12
to google-we...@googlegroups.com
I would not consider this a 'flaw': there is no problem in setting the row count asynchronously, way after having finished initialization. In fact, it is not even possible for the method to 'wait until the value is returned': this is the very point of asynchronous loading. The RPC call may look like the following:
ContactsService.Util.getInstance().getCount(
new AsyncCallback<Integer>() {
@Override
public void onSuccess(Integer result) {
table.setRowCount(result, true);
}
@Override
public void onFailure(Throwable caught) {
Window.alert("error: "+caught);
}
});
The user may notice a short period of time while the table pager shows something like '1-1 of 0' before the row count RPC call returns.

Regards,
--
Reply all
Reply to author
Forward
0 new messages