2

我正在使用我的 GWT 2.3 Celltable 和 SimplePager

通过扩展 SimplePager 类编写 CustomPager。

使用 ListBox 为 celltable 显示不同的页面大小,例如 10,20,50,100

当页面大小为 10 时,我在 celltable 中显示 11 条记录。(1 条空记录(行)+ 10 条记录(行)

当 pageSize = 20 则为 21 行(记录),当 pageSize = 50 则为 51 行(记录),当 pageSize = 100 则为 101 行(记录)。

Whenever selected page size 50 or 100, pager & display returning correct values so pagination working correctly, but not working in case of 10 & 20. Strange :|

调试后发现如下东西:

当页面大小为 10 或 20 时,单击分页器的 lastPage 按钮会得到不正确的分页器 pageIndex 和不正确的 startIndex 值。

错误的 startindex = display.getVisibleRange().getStart()

//Following method called when button click event fires

 protected void onRangeChanged(HasData<RecordVO> display) {

            info("Called onRangeChanged method of AsyncDataProvider");

            eventType = "PAGINATION";

            setPrevPageIndexForChangedRecord();
            cellTable.setRowCount(searchRecordCount, false);

            startRowIndexOfPage = display.getVisibleRange().getStart(); // startRowIndex;
             // ------ My code is here

}

单击寻呼机最后一个按钮时,错误值如下所示,假设页面大小=10,即 1 条虚拟记录 + 10 条实际记录。

    startRowIndexOfPage = display.getVisibleRange().getStart(); // startRowIndex;
    info("Start row index of page = "+startRowIndexOfPage);
    info("GWT Current page index = "+pager.getPage());
    info("GWT Total page count = "+pager.getPageCount());
    info("Gwt Total page size  = "+pager.getPageSize());
    info("Gwt page start index = "+pager.getPageStart());

当页面大小 = 10 时,分页器最后一个按钮的输出 onclick 不正确:

(-:-) 2013-03-05 09:53:22,136 [INFO ] Start row index of page = 990
(-:-) 2013-03-05 09:53:22,150 [INFO ] GWT Current page index = 90
(-:-) 2013-03-05 09:53:22,178 [INFO ] GWT Total page count = 91
(-:-) 2013-03-05 09:53:22,191 [INFO ] Gwt Total page size = 11
(-:-) 2013-03-05 09:53:22,204 [INFO ] Gwt page start index = 990

主要问题是 pager.getPage() 返回 90 而不是最后一页索引:(

有没有办法解决这个问题?请为这个问题提供一些指示/解决方案。

提前致谢。

4

2 回答 2

1

尝试使用以下算术运算找到startRowIndexOfPage-

 startRowIndexOfPage = display.getVisibleRange().getStart() - pager.getPage();

并确保page limit is 10 not 11. 并使您的寻呼机不知道您正在添加的额外空行。

于 2013-03-05T14:51:30.340 回答
0

你试过这样吗??

@Override
protected void onRangeChanged(HasData<YourObject> display) 
{
        int start = display.getVisibleRange().getStart();
        int end  = start + display.getVisibleRange().getLength();                
        if (ListOfYourObjects != null) 
        {
              end = end >= ListOfYourObjects.size() ? ListOfYourObjects.size(): end;
              List<YourObject> sub = ListOfYourObjects.subList(start, end);
              updateRowData(start, sub);
        }   
}
于 2013-03-02T12:24:17.737 回答