首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GWT SimplePager LastButton问题

GWT SimplePager LastButton问题
EN

Stack Overflow用户
提问于 2012-03-22 15:22:17
回答 4查看 3.5K关注 0票数 4

我遇到了SimplePager的lastButton的问题。我在单元格表中有3个页面,页面size=11 (1个空记录+ 10个记录(有值)),总record=26。

我通过扩展SimplePager来使用CustomerPager。

在第一次尝试中,1+10记录显示在单元格表中:启用了下一页和最后一页按钮(禁用了第一页和上一页按钮),这是正确的。但是LastPage按钮不工作..。:(不知道是什么问题...(事件未触发)

奇怪的行为:

@1仅当我访问最后一页(在我的情况下是3页)时,最后一页按钮才有效。

@2假设我在第1页n我移动到第2页(单元格表格中共有3页)。此时所有按钮都被启用,这是正确的。在本例中,Last按钮正在工作,但行为类似于Next按钮

我的GWT应用程序集成到我们的一个产品中,所以无法从客户端对其进行调试。

可能是来自AbstractPager的setPage(int index)方法中的索引值不正确

Last按钮的代码流如下所示

代码语言:javascript
复制
//From SimplePager

lastPage.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
          lastPage();
        }
      });


       @Override
  public void lastPage() {
    super.lastPage();
  }

 // From AbstractPager
  /**
   * Go to the last page.
   */
  protected void lastPage() {
    setPage(getPageCount() - 1);
  }
 protected void setPage(int index) {
    if (display != null && (!isRangeLimited || !display.isRowCountExact() || hasPage(index))) {
      // We don't use the local version of setPageStart because it would
      // constrain the index, but the user probably wants to use absolute page
      // indexes.
      int pageSize = getPageSize();
      display.setVisibleRange(pageSize * index, pageSize);
    }
  }

或者可能是上述代码中的某些条件假(来自setPage())

实际记录= 26条,3条空记录(第一条空记录/页)

dataSize可能有问题:|

如何根据数据大小检查页数??

我该如何解决这个问题?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-05-10 14:49:39

仅在OnRange更改方法AsyncDataProvider中添加了cellTable.setRowCount(int size, boolean isExact)我的问题解决了:)

代码语言:javascript
复制
protected void onRangeChanged(HasData<RecordVO> display) {
//----- Some code --------
cellTable.setRowCount(searchRecordCount, false);
//----- Some code --------
}
票数 0
EN

Stack Overflow用户

发布于 2012-03-27 18:23:35

编辑:我发现寻呼机的默认构造函数没有给你一个“最后”按钮,而是一个“快进1000行”按钮(可怕,对吧?)。

像这样调用下面的构造函数,并看到问题得到了解决:

SimplePager.Resources resources = GWT.create(SimplePager.Resources.class); SimplePager simplePager = new SimplePager(TextLocation.CENTER, resources , false, 1000, true);

第一个"false“标志关闭"fastforward button”,最后一个"true“标志打开" last”按钮。

此外,只有当寻呼机知道您的记录总数时,最后一个按钮才会起作用。

您可以调用表的setRowCount函数来更新总数,如下所示:

int totalRecordsSize = 26; //the total amount of records you have boolean isTotalExact = true; //is it an estimate or an exact match table.setRowCount(totalRecordsSize , isTotalExact); //sets the table's total and updates the pager (assuming you called pager.setDisplay(table) before)

如果你使用的是一个附加的DataProvider,那么它就都是updateRowCount方法(用法相同)。

票数 3
EN

Stack Overflow用户

发布于 2012-03-26 13:04:14

在没有看到更多代码的情况下,这是一个很难回答的问题,因为可能会有多个地方出错。

我会确保你在你的SimplePager上调用setDisplay(...),这样它就有了需要的数据来计算它的范围。

如果您不能在devmode中运行,我建议在浏览器中设置一些GWT日志(将日志写入弹出式面板或其他地方,例如see this discussion )。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9817988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档