Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt SimplePage行计数工作不正确_Gwt - Fatal编程技术网

Gwt SimplePage行计数工作不正确

Gwt SimplePage行计数工作不正确,gwt,Gwt,我使用的是simplepage,我希望每页显示12个项目(用户)。我的整个数据集有20项 问题是第一页(正确)显示了项目1-12,但第二页显示了项目9-20。我希望第二页显示项目13-20 怎么了 这是我的密码: CellTable<User> cellTable = new CellTable<User>(); SimplePager pager = new SimplePager(TextLocation.CENTER); pager.setDispla

我使用的是
simplepage
,我希望每页显示12个项目(用户)。我的整个数据集有20项

问题是第一页(正确)显示了项目1-12,但第二页显示了项目9-20。我希望第二页显示项目13-20

怎么了

这是我的密码:

CellTable<User> cellTable = new CellTable<User>();

SimplePager pager = new SimplePager(TextLocation.CENTER);      
pager.setDisplay(cellTable);    
pager.setPageSize(12);


ListDataProvider<User> dataProvider = new ListDataProvider<User>();<br>
dataProvider.setList(USERSList);  
dataProvider.addDataDisplay(cellTable);
CellTable CellTable=new CellTable();
SimplePager pager=新SimplePager(TextLocation.CENTER);
寻呼机设置显示(手机台);
寻呼机设置页面大小(12);
ListDataProvider dataProvider=新ListDataProvider()
dataProvider.setList(USERSList); dataProvider.addDataDisplay(cellTable);
提前谢谢你

尝试设置:

setRangeLimited(false)
更多详情:

设置

setRangeLimited(false)
将始终显示下一页

相反,我将rangeLimited设置为true,并为此重写了以下方法:

@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);
    }
  }
}

@fbfcn和@MasterUZ的解决方案有效,只需稍作修改,即可使其符合GWT 2.4的SimplePager:

public class MySimplePager extends SimplePager {

    public MySimplePager() {
        this.setRangeLimited(true);
    }

    public MySimplePager(TextLocation location, Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton) {
        super(location, resources, showFastForwardButton, fastForwardRows, showLastPageButton);
        this.setRangeLimited(true);
    }

    public void setPageStart(int index) {

        if (this.getDisplay() != null) {
          Range range = getDisplay().getVisibleRange();
          int pageSize = range.getLength();
          if (!isRangeLimited() && getDisplay().isRowCountExact()) {
            index = Math.min(index, getDisplay().getRowCount() - pageSize);
          }
          index = Math.max(0, index);
          if (index != range.getStart()) {
            getDisplay().setVisibleRange(index, pageSize);
          }
        }  
      }
    }

很好,但是禁用无休止的“hasnextpage”错误的诀窍不起作用,你认为呢???@Fabio,下面的解决方案有效,并克服了hasnextpage问题这一个!适用于GWT 2.5.1
public class MySimplePager extends SimplePager {

    public MySimplePager() {
        this.setRangeLimited(true);
    }

    public MySimplePager(TextLocation location, Resources resources, boolean showFastForwardButton, int fastForwardRows, boolean showLastPageButton) {
        super(location, resources, showFastForwardButton, fastForwardRows, showLastPageButton);
        this.setRangeLimited(true);
    }

    public void setPageStart(int index) {

        if (this.getDisplay() != null) {
          Range range = getDisplay().getVisibleRange();
          int pageSize = range.getLength();
          if (!isRangeLimited() && getDisplay().isRowCountExact()) {
            index = Math.min(index, getDisplay().getRowCount() - pageSize);
          }
          index = Math.max(0, index);
          if (index != range.getStart()) {
            getDisplay().setVisibleRange(index, pageSize);
          }
        }  
      }
    }