Search code examples
gwtpaginationgwt-celltable

GWT CellTable getVisibleRange() is not what i except


GWT2.4, CellTable with SimplePager, every page show 5 items(rows), suppose i have 8 items totally, at the first page i can see [1-5], when i press next, it will show [4-8] ( getVisibleRange() is [4-8]), i want it to show [6-8], Is there any way i can achieve this?

Thanks in advance.


Solution

  • Try setting

    setRangeLimited(false)
    

    with SimplePager

    Or you can also override

    @Override
    public void setPageStart(int index) {
      if (getDisplay() != null) {
        Range range = getDisplay().getVisibleRange();
        int pageSize = range.getLength();
    
        // Removed the min to show fixed ranges
        //if (isRangeLimited && display.isRowCountExact()) {
        //  index = Math.min(index, display.getRowCount() - pageSize);
        //}
    
        index = Math.max(0, index);
        if (index != range.getStart()) {
          getDisplay().setVisibleRange(index, pageSize);
        }
      }