From 4c2a5effa4b435b80551d4aff08fc86c013fd54d Mon Sep 17 00:00:00 2001 From: Alexandru Prigoreanu Date: Tue, 21 Jan 2020 12:27:07 -0500 Subject: [PATCH] refs #34 : TableSelectionModel - shift-select does not loose first selected items anymore. --- .../tableselection/TableSelectionModel.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/GridExtensionPack/src/main/java/org/vaadin/teemusa/gridextensions/tableselection/TableSelectionModel.java b/GridExtensionPack/src/main/java/org/vaadin/teemusa/gridextensions/tableselection/TableSelectionModel.java index a3baa7a..91f44a3 100644 --- a/GridExtensionPack/src/main/java/org/vaadin/teemusa/gridextensions/tableselection/TableSelectionModel.java +++ b/GridExtensionPack/src/main/java/org/vaadin/teemusa/gridextensions/tableselection/TableSelectionModel.java @@ -23,14 +23,14 @@ *

* This is a SelectionModel for SelectGrid, use * {@link SelectGrid#setSelectionModel(GridSelectionModel)} to take it into use. - * + * * @author Teemu Suo-Anttila */ public class TableSelectionModel extends MultiSelectionModelImpl { /** * Set the TableSelectionMode to use with this extension. - * + * * @param mode * table-like selection mode */ @@ -67,14 +67,17 @@ public void selectRange(int start, int length) { */ return comparator1.thenComparing(comparator2)::compare; }; - Comparator inMemorySorting = getParent().getSortOrder().stream() + final Grid grid = getParent(); + Comparator inMemorySorting = grid.getSortOrder().stream() .map(order -> order.getSorted().getComparator(order.getDirection())) .reduce((x, y) -> 0, operator); List sortProperties = new ArrayList<>(); - getParent().getSortOrder().stream().map(order -> order.getSorted().getSortOrder(order.getDirection())) + grid.getSortOrder().stream().map(order -> order.getSorted().getSortOrder(order.getDirection())) .forEach(s -> s.forEach(sortProperties::add)); - getParent().getDataProvider().fetch(new Query<>(start, length, sortProperties, inMemorySorting, null)); + grid.getDataProvider().fetch(new Query<>(start, length, sortProperties, inMemorySorting, null)) + .forEach(grid::select); + } }); }