From: Artur Signell Date: Fri, 20 Feb 2015 22:12:09 +0000 (+0200) Subject: Make Column.setLastFrozenColumn work (#16726) X-Git-Tag: 7.5.0.alpha1~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7a05a85dd10d2ca61c222943d5b1bc9963fd4987;p=vaadin-framework.git Make Column.setLastFrozenColumn work (#16726) Change-Id: I58fee1549459b24cb47e0d3321d16fb8b215959a --- diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 2bc42676c3..a32968bd73 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -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; } diff --git a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java index 06c1b14bb6..fda662e4d9 100644 --- a/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java +++ b/server/tests/src/com/vaadin/tests/server/component/grid/GridColumns.java @@ -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,