GWT 2.5.1 CellTable和SimplePager问题

时间:2014-01-23 17:05:08

标签: java gwt

我正在使用GWT 2.5.1。我有一个CellTable,其中分页由SimplePager完成。我看到了SimplePager的以下问题。

  1. 最后一页显示的行数不正确。假设共有22行,页面大小设置为10.因此,第三页应显示22-22。相反,它显示为22-22。最后一页总是显示10行,需要一些来自上一页。
  2. 没有最后一页按钮。有一个快进按钮也被禁用。
  3. 如果没有数据,则文字显示为1-1的0。
  4. 我知道这些都是已知问题,因为我对这个主题进行了大量研究。想知道GWT 2.5.1中是否仍然没有修复这个问题。有可用的包装吗?针对此错误的任何解决方法? 我正在编写我的自定义寻呼机,它扩展了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);
        }
    
        @Override
        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);
              }
            }  
          }
    }
    

    我将寻呼机实例化为:

    SimplePager.Resources resources = GWT.create(SimplePager.Resources.class); 
    
    usersPager = new MySimplePager(SimplePager.TextLocation.CENTER, resources, false,10, true);
    

    但是,这根本不起作用。奇怪的是,方法setPageStart()在任何时候都没有被调用。我在其中添加了一些日志消息,但它们没有显示出来。我在这里做错了什么或丢失了什么? 任何帮助将不胜感激。

    感谢。

1 个答案:

答案 0 :(得分:0)

我没有遇到你的前两个问题。第二个问题出现在2.5.1 RC1版本中,但已在2.5.1版本中得到纠正。

1)有一些黑客可以克服这个问题,但我忘记了它是什么。 2)使用以下构造函数启用fastforward按钮和最后一页按钮

public SimplePager(TextLocation location, boolean showFastForwardButton,
      boolean showLastPageButton)

3)这已在最新版本中修复。

For more info check out this.

相关问题