diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-08-18 12:03:36 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-08-18 12:03:36 +0300 |
commit | 563b0abb73c5c1a29763b3c1f39f56e876704357 (patch) | |
tree | 9b067d6d52f1408ea68e6771406d6dacdc5c8e08 | |
parent | d9b8199a708bf328088674dab4265293fdb2ff95 (diff) | |
download | vaadin-framework-563b0abb73c5c1a29763b3c1f39f56e876704357.tar.gz vaadin-framework-563b0abb73c5c1a29763b3c1f39f56e876704357.zip |
Fix state update on Grid Column hide in client (#9836)
Fixes #9152
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 5 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java | 21 |
2 files changed, 22 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 2828742ee6..663df20b88 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -681,9 +681,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, @Override public void columnVisibilityChanged(String internalId, boolean hidden) { Column<T, ?> column = getColumnByInternalId(internalId); - ColumnState columnState = column.getState(false); - if (columnState.hidden != hidden) { - columnState.hidden = hidden; + if (column.isHidden() != hidden) { + column.setHidden(hidden); fireColumnVisibilityChangeEvent(column, hidden, true); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java index a8a1d8f229..e1b5939ead 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java @@ -26,8 +26,8 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.By; -import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.LabelElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -89,6 +89,25 @@ public class GridColumnHidingTest extends MultiBrowserTest { } @Test + public void clientHideServerShowColumns() { + openTestURL(); + GridElement grid = $(GridElement.class).first(); + + getSidebarOpenButton(grid).click(); + // Assuming client-side hiding works. See clientHideColumns() + getColumnHidingToggle(grid, "custom age column caption").click(); + getColumnHidingToggle(grid, "Name").click(); + + // Show from server + $(ButtonElement.class).caption("server side toggle age column").first() + .click(); + Assert.assertEquals("46", grid.getCell(0, 0).getText()); + Assert.assertEquals("18", grid.getCell(1, 0).getText()); + Assert.assertEquals("yeah@cool.com", grid.getCell(0, 1).getText()); + Assert.assertEquals("maya@foo.bar", grid.getCell(1, 1).getText()); + } + + @Test public void columnVisibilityChangeListener() { openTestURL(); GridElement grid = $(GridElement.class).first(); |