简体   繁体   English

如何获取GWT CellTable分页的总行数

[英]How to get the total row count for GWT CellTable pagination in

I'm trying to implement paging in a CellTable but it's currently showing "1-10 of 10" records instead of "1-10 of 1000" records. 我正在尝试在CellTable中实现分页,但它当前显示“1-10 of 10”记录而不是“1-10 of 1000”记录。 I'm not sure where I can update the total record count. 我不确定在哪里可以更新总记录数。 My AsyncDataProvider looks like this: 我的AsyncDataProvider看起来像这样:

    AsyncDataProvider<OutletSearchVO> latestProvider = new AsyncDataProvider<OutletSearchVO>() {

        @Override
        protected void onRangeChanged(HasData<OutletSearchVO> display) {
            final int start = display.getVisibleRange().getStart();
            int length = display.getVisibleRange().getLength();
            AsyncCallback<List<OutletSearchVO>> callback = new AsyncCallback<List<OutletSearchVO>>() {
                @Override
                public void onFailure(Throwable caught) {
                    Window.alert(caught.getMessage());
                }

                @Override
                public void onSuccess(List<OutletSearchVO> result) {
                    updateRowData(start, result);
                }
            };
            // The remote service that should be implemented
            service.getOutletPage(start, length, callback);

        }
    };

The SQL I'm using to grab the records is similar to this: 我用来抓取记录的SQL类似于:

SELECT *
  FROM (SELECT outlet_id,
           outlet_name,
           image,
           ROWNUM rn
      FROM (  SELECT outlet_id outlet_id,
                     account_name outlet_name,
                     image_score image,
                FROM outlets)
            ORDER BY OOI.created_on DESC, OOI.account_name))
WHERE rn > ? AND rn < ?    

The question marks are replaced by the start and end range in a prepared statement. 问号由准备好的声明中的开始和结束范围替换。

You have to call updateRowCount from within your AsyncDataProvider (similar to how you call updateRowData ), which means you have to ask your server for that count (or at least an approximation, and then choose whether you pass a true or false as the second argument to updateRowCount ). 您必须从AsyncDataProvider调用updateRowCount (类似于调用updateRowData ),这意味着您必须向服务器询问该计数(或至少是近似值,然后选择是否传递truefalse作为第二个参数to updateRowCount )。

Of course, you can also call updateRowCount from outside the onRangeChange , particularly if you can know upfront how many rows you'll have, and that number is not going to change that much. 当然,您也可以从onRangeChange外部调用updateRowCount ,特别是如果您可以预先了解您将拥有多少行,并且该数字不会发生太大变化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM