4

我面临 SimplePager 的 lastButton 的问题。我在单元格表中有 3 页,页面大小 = 11(1 条空记录 + 10 条记录(带值)),总记录 = 26。

我通过扩展 SimplePager 来使用 CustomerPager。

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

奇怪的行为:

@1 最后一页按钮仅在我访问最后一页时才起作用(在我的情况下为 3 页)。

@2 假设我在第一页 n 我移到了第二页(单元格表中总共 3 页)。那时所有按钮都已启用,这是正确的。在这种情况下,最后一个按钮正在工作,但行为类似于下一个按钮

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

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

Last按钮的代码流程如下

//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 空记录(第 1 个空记录/页)

数据大小可能有问题:|

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

我怎么解决这个问题?

4

4 回答 4

3

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

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

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

第一个“false”标志关闭“快进按钮”,最后一个“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 方法(使用相同)。

于 2012-03-27T10:23:34.733 回答
0

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

protected void onRangeChanged(HasData<RecordVO> display) {
//----- Some code --------
cellTable.setRowCount(searchRecordCount, false);
//----- Some code --------
}
于 2012-05-10T06:49:39.493 回答
0

我认为问题与setPage(). 尝试在if条件之前放置 SOP 或调试代码

于 2012-03-29T11:49:42.863 回答
0

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

我会确保您调用setDisplay(...)您的 SimplePager,以便它拥有计算其范围所需的数据。

如果您不能在 devmode 下运行,我建议在浏览器中设置一些 GWT 日志记录(将日志写入弹出面板或其他内容,请参阅此讨论以获取示例)。

于 2012-03-26T05:04:13.747 回答