diff --git a/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionGrid.java b/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionGrid.java index 3f5777a..6563ee8 100644 --- a/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionGrid.java +++ b/selection-grid-flow/src/main/java/com/vaadin/componentfactory/selectiongrid/SelectionGrid.java @@ -180,7 +180,7 @@ private Set obtainNewSelectedItems(int fromIndex, int toIndex) { int from = Math.min(fromIndex, toIndex); int to = Math.max(fromIndex, toIndex) + 1; int pageSize = dataCommunicator.getPageSize(); - if (to - from < (pageSize * 2) - 3) { + if (dataCommunicator.getItemCount() > 0 && to - from < (pageSize * 2) - 3) { // if the range to be retrieved is smaller than 2 pages // ask the dataCommunicator to retrieve the items so the cache is used for(int i = from; i < to; i++) {