【问题标题】:GWT 2.5.1 CellTable and SimplePager issueGWT 2.5.1 CellTable 和 SimplePager 问题
【发布时间】:2014-01-23 17:05:08
【问题描述】:

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

  1. 最后一页显示的行数不正确。假设总共有 22 行,页面大小设置为 10。所以,第三页应该显示 22 的 21-22。相反,它显示 22 的 13-22。最后一页总是显示 10 行,它需要一些从上一页。
  2. 没有最后一页按钮。有一个快进按钮也被禁用。
  3. 当没有数据时,文本显示 1-1 of 0。

我知道这些是已知问题,因为我对此主题进行了大量研究。想知道这是否在 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() 方法在任何时候都没有被调用。我在其中放了一些日志消息,但没有显示出来。我在这里做错了什么或遗漏了什么? 任何帮助将不胜感激。

谢谢。

【问题讨论】:

  • 奇怪,该解决方法适用于 GWT 2.5.1,我确实看到了最后一页按钮。我想知道它是否与表的 dataProvider 或它的更新方式有关。你能展示一下你的 CellTable 类的代码吗?
  • 你说它根本不起作用是什么意思?而不是日志语句只需在开发人员模式下运行并在 setPageStart 的第一行放置一个断点。

标签: java gwt


【解决方案1】:

我没有遇到您的前 2 个问题。第三个问题存在于 2.5.1 RC1 版本中,但已在 2.5.1 版本中得到纠正。

1) 有一些技巧可以克服这个问题,但我忘记了它是什么。 2) 使用下面的构造函数来启用快进按钮和最后一页按钮

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

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

For more info check out this.

【讨论】:

    猜你喜欢
    • 2017-06-15
    • 2012-04-06
    • 2011-11-28
    • 2013-04-10
    • 2012-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多