Tuesday, November 2, 2010

Re: AsyncDataProvider's updateRowCount(int, boolean) method doesn't behave correctly on the last page

Are you using a SimplePager?  The pager isn't setting the page range intuitively, and a lot of users have been complaining.  We'll take another look for GWT 2.1.1.

Thanks,
John LaBanca
jlabanca@google.com


On Tue, Nov 2, 2010 at 6:17 AM, Geoffrey De Smet <ge0ffrey.spam@gmail.com> wrote:
Hi,

I am using AsyncDataProvider and in my testcase I have 3 pages:
  • First page: 1 to 10, renders correctly as 1-10 of 23
  • Second page: 11 to 20, renders correctly as 11-20 of 23
  • Last page: 21 to 23, renders wrong as 14-23 of 23 instead of 21-23 of 23
    • The data is messed up
    • Going back to the second page messes up the second page too
I checked the start and pageSizes being send to the server for the last page: they are correct.
I do 2 things in my server callback:
  • updateRowCount((int) result.getTotal(), true);
    • Removing that line fixes the problem, but then it reports 21-23 of above 23
      • The tutorials recommend of setting the row count
  • updateRowData(start, result.getRowList());
Here's the full code:

AsyncDataProvider<TableDataRow> dataProvider = new AsyncDataProvider<TableDataRow>() {
    protected void onRangeChanged(HasData<TableDataRow> display) {
        final int start = pager.getPage() * pageSize;
        server.loadData(start, pageSize,
                 new GenericCallback<TableDataResult>() {
                     public void onSuccess(TableDataResult result) {
                         updateRowCount((int) result.getTotal(), true); // Without this line it works perfect, with it it doesn't on the last page
                         updateRowData(start, result.getRowList());
                     }
                 });
    }
};
--  With kind regards, Geoffrey De Smet

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment