]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make Column.setLastFrozenColumn work (#16726)
authorArtur Signell <artur@vaadin.com>
Fri, 20 Feb 2015 22:12:09 +0000 (00:12 +0200)
committerVaadin Code Review <review@vaadin.com>
Mon, 23 Feb 2015 12:50:31 +0000 (12:50 +0000)
Change-Id: I58fee1549459b24cb47e0d3321d16fb8b215959a

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

index 2bc42676c3a06dd1a3a455d7abf5d0ea191e6dcd..a32968bd738666345691fce5386729b780087a47 100644 (file)
@@ -2197,7 +2197,7 @@ public class Grid extends AbstractComponent implements SelectionNotifier,
         public Column setLastFrozenColumn() {
             checkColumnIsAttached();
             grid.setFrozenColumnCount(grid.getState(false).columnOrder
-                    .indexOf(this) + 1);
+                    .indexOf(getState().id) + 1);
             return this;
         }
 
index 06c1b14bb60a51f42e309f55d5897ecdbfa8c3ca..fda662e4d9e9f6f59f0a47cb984b63b4d9659f3e 100644 (file)
@@ -184,6 +184,25 @@ public class GridColumns {
         assertTrue(state.footer.visible);
     }
 
+    @Test
+    public void testSetFrozenColumnCount() {
+        assertEquals("Grid should not start with a frozen column", 0,
+                grid.getFrozenColumnCount());
+        grid.setFrozenColumnCount(2);
+        assertEquals("Freezing two columns should freeze two columns", 2,
+                grid.getFrozenColumnCount());
+    }
+
+    @Test
+    public void testSetFrozenColumnCountThroughColumn() {
+        assertEquals("Grid should not start with a frozen column", 0,
+                grid.getFrozenColumnCount());
+        grid.getColumns().get(2).setLastFrozenColumn();
+        assertEquals(
+                "Setting the third column as last frozen should freeze three columns",
+                3, grid.getFrozenColumnCount());
+    }
+
     @Test
     public void testFrozenColumnRemoveColumn() {
         assertEquals("Grid should not start with a frozen column", 0,