【问题标题】:GWT DataGrid with SimplePager, Last Page IssueGWT DataGrid 与 SimplePager,最后一页问题
【发布时间】:2016-03-10 18:32:14
【问题描述】:

我正在使用 GWT DataGrid 和 SimplePager 来显示我的数据,

组件正确显示第一页,但最后一页始终显示 10 行 (10 = SimplePager.pagesize),即使我们要显示的行少于 10 行。

有人对你的问题有想法吗?

谢谢。

【问题讨论】:

  • 你能给我们看看代码吗?

标签: gwt datagrid simplepager


【解决方案1】:

我之前遇到过类似的问题。小的区别是我使用的是 Celltable 而不是 DataGrid。

问题来自一个已知的 gwt 错误,您可以在 its github page 上查看详细信息。显然它已经修复了。

解决方法是继承 SimplePager 并创建您的自定义寻呼机类。

import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.view.client.Range;

public class CustomPager extends SimplePager {

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

@Override
public void setPageStart(int index) {
    if (this.getDisplay() != null) {
        Range range = this.getDisplay().getVisibleRange();
        int pageSize = range.getLength();
        index = Math.max(0, index);
        if (index != range.getStart()) {
            this.getDisplay().setVisibleRange(index, pageSize);
        }
    }
}

}

【讨论】:

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