diff options
author | Artur Signell <artur@vaadin.com> | 2016-10-15 23:02:15 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2016-10-18 05:15:30 +0000 |
commit | 04650c56543a446008b8e379a56576472b8e093e (patch) | |
tree | b8b7dc44c8659561f99ede9e86bf8df3b1ecf131 | |
parent | 643365176aeae6edd28fcdd9f98602dec7a80e77 (diff) | |
download | vaadin-framework-04650c56543a446008b8e379a56576472b8e093e.tar.gz vaadin-framework-04650c56543a446008b8e379a56576472b8e093e.zip |
Update client side selection state when changing selection model (#20370)
Change-Id: I7fe8c160405a69140cac511c744d89a62c401cca
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 4 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java | 40 |
2 files changed, 44 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 3f61dcd88f..3bce7fcc39 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -5595,6 +5595,10 @@ public class Grid extends AbstractFocusable implements SelectionNotifier, if (!SharedUtil.equals(oldSelection, newSelection)) { fireSelectionEvent(oldSelection, newSelection); } + + // selection is included in the row data, so the client needs to be + // updated + datasourceExtension.refreshCache(); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java index bd2380ee45..a1dc542250 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/server/GridSelectionTest.java @@ -426,4 +426,44 @@ public class GridSelectionTest extends GridBasicFeaturesTest { private GridRowElement getRow(int i) { return getGridElement().getRow(i); } + + @Test + public void changeSelectionModelSingleToNone() throws Exception { + openTestURL(); + + setSelectionModelSingle(); + getGridElement().getCell(0, 0).click(); + assertTrue("row should become selected", getRow(0).isSelected()); + setSelectionModelNone(); + assertFalse("row should become deselected", getRow(0).isSelected()); + setSelectionModelSingle(); + assertFalse("row should still be deselected", getRow(0).isSelected()); + getGridElement().getCell(0, 0).click(); + assertTrue("row should become selected", getRow(0).isSelected()); + } + + @Test + public void changeSelectionModelMultiToNone() throws Exception { + openTestURL(); + + setSelectionModelMulti(); + getGridElement().getCell(0, 0).click(); + getGridElement().getCell(1, 0).click(); + getGridElement().getCell(2, 0).click(); + assertTrue("row should become selected", getRow(0).isSelected()); + assertTrue("row should become selected", getRow(1).isSelected()); + assertTrue("row should become selected", getRow(2).isSelected()); + + setSelectionModelNone(); + assertFalse("row should become deselected", getRow(0).isSelected()); + assertFalse("row should become deselected", getRow(1).isSelected()); + assertFalse("row should become deselected", getRow(2).isSelected()); + setSelectionModelMulti(); + assertFalse("row should still be deselected", getRow(0).isSelected()); + assertFalse("row should still be deselected", getRow(1).isSelected()); + assertFalse("row should still be deselected", getRow(2).isSelected()); + + getGridElement().getCell(0, 0).click(); + assertTrue("row should become selected", getRow(0).isSelected()); + } } |