]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix state update on Grid Column hide in client (#9836)
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>
Fri, 18 Aug 2017 09:03:36 +0000 (12:03 +0300)
committerHenri Sara <henri.sara@gmail.com>
Fri, 18 Aug 2017 09:03:36 +0000 (12:03 +0300)
Fixes #9152

server/src/main/java/com/vaadin/ui/Grid.java
uitest/src/test/java/com/vaadin/tests/components/grid/GridColumnHidingTest.java

index 2828742ee6de3d72ccd6e7e2d296a81f035e24a9..663df20b88993ef5f805024b22ffb282319e828b 100644 (file)
@@ -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);
             }
         }
index a8a1d8f229649023fe1e91d8db4605ca4824ddf7..e1b5939ead9bb529fa4a935295d9f9dc49a72bf7 100644 (file)
@@ -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;
@@ -88,6 +88,25 @@ public class GridColumnHidingTest extends MultiBrowserTest {
         Assert.assertEquals("maya@foo.bar", grid.getCell(1, 1).getText());
     }
 
+    @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();