2014-01-23 91 views
1

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

  1. 最后一页显示的行数不正确。假设总共有22行,页面大小设置为10.因此,第三页应显示22的21-22。相反,它显示22的13-22。最后一页始终显示10行,它需要一些从前一页。
  2. 没有最后一页按钮。有一个快进按钮也被禁用。
  3. 当没有数据,文中说0. 1-1

我知道这些都是已知的问题,因为我做了很多的研究这个话题。想知道这在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()方法在任何时候都没有被调用。我在里面放了一些日志消息,但没有显示。我在这里做错了什么或错过? 任何帮助将不胜感激。

谢谢。

+0

奇怪了,那解决方法对我的作品与GWT 2.5.1和我看到最后一页按钮。我想知道它是否可能与表的dataProvider或它更新的方式有关。你能显示你的CellTable类的代码吗? –

+0

你的意思是什么都不起作用?而不是日志语句只能在开发人员模式下运行,并在setPageStart的第一行放置一个断点。 – bdrx

回答

0

我不面对你的第2个问题。第三个问题出现在2.5.1 RC1版本中,但是它在2.5.1版本中得到纠正。

1)有窍门可以克服这一点,但我忘了它是什么。 2)使用下面的构造,使fastforwardbutton页和最后一页按钮

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

3)这是固定的最新版本。

For more info check out this.