From 54360ceb4c246f3e32859886dac5a16285080974 Mon Sep 17 00:00:00 2001 From: Piotr Ostrowski Date: Wed, 28 Mar 2018 11:04:17 +0200 Subject: [PATCH] prevent sending smaller limit value to the datasource for the last page --- .../client/ui/pager/MaterialDataPager.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/gwt/material/design/client/ui/pager/MaterialDataPager.java b/src/main/java/gwt/material/design/client/ui/pager/MaterialDataPager.java index df9eb0a5..d5fa786e 100644 --- a/src/main/java/gwt/material/design/client/ui/pager/MaterialDataPager.java +++ b/src/main/java/gwt/material/design/client/ui/pager/MaterialDataPager.java @@ -165,18 +165,20 @@ public boolean isLastPage() { protected void doLoad(int offset, int limit) { this.offset = offset; - // Check whether the pager has excess rows with given limit - if (isLastPage() & isExcess()) { - // Get the difference between total rows and excess rows - limit = totalRows - offset; - } - - int finalLimit = limit; dataSource.load(new LoadConfig<>(offset, limit, table.getView().getSortContext(), table.getView().getOpenCategories()), new LoadCallback() { @Override public void onSuccess(LoadResult loadResult) { totalRows = loadResult.getTotalLength(); + + int finalLimit = limit; + + // Check whether the pager has excess rows with given limit + if (isLastPage() & isExcess()) { + // Get the difference between total rows and excess rows + finalLimit = totalRows - offset; + } + table.setVisibleRange(offset, finalLimit); table.loaded(loadResult.getOffset(), loadResult.getData()); updateUi();