]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix Grid Header/Footer creating cells for unused properties (#15487)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 31 Dec 2014 10:37:52 +0000 (12:37 +0200)
committerLeif Åstrand <leif@vaadin.com>
Fri, 2 Jan 2015 11:32:28 +0000 (11:32 +0000)
Change-Id: I783fa6fdb44b0d5693723fc52cdb7fed3499dea1

server/src/com/vaadin/ui/Grid.java
server/tests/src/com/vaadin/tests/server/component/grid/GridStaticSectionTest.java

index 0f6912be1adf427e7a5f7411ee7e57614a1a9283..d61458297a912ee01c362947a297deb574ec14c7 100644 (file)
@@ -1487,8 +1487,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
             rows.add(index, row);
             getSectionState().rows.add(index, row.getRowState());
 
-            Indexed dataSource = grid.getContainerDataSource();
-            for (Object id : dataSource.getContainerPropertyIds()) {
+            for (Object id : grid.columns.keySet()) {
                 row.addCell(id);
             }
 
index c0b4afbdbeac4a365663fd728fd38562b1711ff4..4031886e7ac27165a7ad25e04e2db2e0b93003ec 100644 (file)
@@ -16,6 +16,8 @@
 package com.vaadin.tests.server.component.grid;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.lang.reflect.Method;
 
@@ -72,6 +74,24 @@ public class GridStaticSectionTest extends Grid {
         assertEquals(0, getFooterRowCount());
     }
 
+    @Test
+    public void testUnusedPropertyNotInCells() {
+        removeColumn("firstName");
+        assertNull("firstName cell was not removed from existing row",
+                getDefaultHeaderRow().getCell("firstName"));
+        HeaderRow newRow = appendHeaderRow();
+        assertNull("firstName cell was created when it should not.",
+                newRow.getCell("firstName"));
+        addColumn("firstName");
+        assertNotNull(
+                "firstName cell was not created for default row when added again",
+                getDefaultHeaderRow().getCell("firstName"));
+        assertNotNull(
+                "firstName cell was not created for new row when added again",
+                newRow.getCell("firstName"));
+
+    }
+
     @Test
     public void testJoinHeaderCells() {
         HeaderRow mergeRow = prependHeaderRow();