Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT - celltable with simple pager issue

Tags:

gwt

The cell table pagination is behaving weirdly. check the example from GWT http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTable

The page size here is defined as 15. This is the problem-

  1. click on last page button. Results for 241 to 250 are shown.
  2. Now click on previous button - results from 226-240 are shown.
  3. Now click on next button ( this is where the problem is). It showns results from 236 to 250. Whereas it should have displyed 241-250.

I am having same issue in my project. Is there any fix for this ??

like image 513
ravi Avatar asked Dec 05 '11 20:12

ravi


2 Answers

This is a known, reported bug. As mentioned in that bug report, there is a workaround:

As workaround, one can subclass SimplePager in order to override this behaviour defined in method setPageStart:

@Override
public void setPageStart(int index) {
    if (this.getDisplay() != null) {
        Range range = this.getDisplay().getVisibleRange();
        int pageSize = range.getLength();
//      if (isRangeLimited && display.isRowCountExact()) {
//          index = Math.min(index, display.getRowCount() - pageSize);
//      }
        index = Math.max(0, index);
        if (index != range.getStart()) {
            this.getDisplay().setVisibleRange(index, pageSize);
        }
    }
}
like image 162
Chris Cashwell Avatar answered Nov 15 '22 09:11

Chris Cashwell


When you make the pager initialization you must set:

pager.setRangeLimited(false);

This method sets whether or not the page range should be limited to the actual data size.

If true, all operations will adjust so that there is always data visible on the page.

like image 27
Nicolas Finelli Avatar answered Nov 15 '22 10:11

Nicolas Finelli