diff options
author | Artur Signell <artur@vaadin.com> | 2015-06-02 00:07:06 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-06-05 22:14:42 +0000 |
commit | 220b407724791d7483f21d6a27d9957beee5a843 (patch) | |
tree | f1074cd5b93112c31d9772fe631b275fbf8a2d8f | |
parent | d5381626ec2e058ac7fb31c4af789b248df92669 (diff) | |
download | vaadin-framework-220b407724791d7483f21d6a27d9957beee5a843.tar.gz vaadin-framework-220b407724791d7483f21d6a27d9957beee5a843.zip |
Insert columns using correct logical row index (#18103)
Change-Id: I7010f4ca938e29c0b348aac15581c0aeb48d2dc0
-rw-r--r-- | client/src/com/vaadin/client/widgets/Escalator.java | 14 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java | 46 |
2 files changed, 57 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/widgets/Escalator.java b/client/src/com/vaadin/client/widgets/Escalator.java index bb497e7e13..55462d18fe 100644 --- a/client/src/com/vaadin/client/widgets/Escalator.java +++ b/client/src/com/vaadin/client/widgets/Escalator.java @@ -1645,7 +1645,8 @@ public class Escalator extends Widget implements RequiresResize, for (int row = 0; row < getDomRowCount(); row++) { final TableRowElement tr = getTrByVisualIndex(row); - paintInsertCells(tr, row, offset, numberOfColumns); + int logicalRowIndex = getLogicalRowIndex(tr); + paintInsertCells(tr, logicalRowIndex, offset, numberOfColumns); } reapplyRowWidths(); @@ -2127,6 +2128,11 @@ public class Escalator extends Widget implements RequiresResize, * @return the height of this table section */ protected abstract double getHeightOfSection(); + + protected int getLogicalRowIndex(final TableRowElement tr) { + return tr.getSectionRowIndex(); + }; + } private abstract class AbstractStaticRowContainer extends @@ -3396,7 +3402,8 @@ public class Escalator extends Widget implements RequiresResize, } } - private int getLogicalRowIndex(final Element tr) { + @Override + protected int getLogicalRowIndex(final TableRowElement tr) { assert tr.getParentNode() == root : "The given element isn't a row element in the body"; int internalIndex = visualRowOrder.indexOf(tr); return getTopRowLogicalIndex() + internalIndex; @@ -3854,7 +3861,8 @@ public class Escalator extends Widget implements RequiresResize, } // Convert DOM coordinates to logical coordinates for rows - Element rowElement = cell.getElement().getParentElement(); + TableRowElement rowElement = (TableRowElement) cell.getElement() + .getParentElement(); return new Cell(getLogicalRowIndex(rowElement), cell.getColumn(), cell.getElement()); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java index 9f63c2b177..6392ee6a22 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java @@ -864,6 +864,52 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest { } + @Test + public void hideScrollAndShow() { + toggleHidableColumnAPI(1); + toggleHideColumnAPI(1); + + getGridElement().scrollToRow(500); + Assert.assertEquals("(500, 0)", getGridElement().getCell(500, 0) + .getText()); + Assert.assertEquals("(500, 2)", getGridElement().getCell(500, 1) + .getText()); + + toggleHideColumnAPI(1); + + Assert.assertEquals("(500, 0)", getGridElement().getCell(500, 0) + .getText()); + Assert.assertEquals("(500, 1)", getGridElement().getCell(500, 1) + .getText()); + } + + @Test + public void scrollHideAndShow() { + toggleHidableColumnAPI(0); + toggleHidableColumnAPI(1); + + Assert.assertEquals("(500, 0)", getGridElement().getCell(500, 0) + .getText()); + Assert.assertEquals("(500, 1)", getGridElement().getCell(500, 1) + .getText()); + + toggleHideColumnAPI(0); + toggleHideColumnAPI(1); + + Assert.assertEquals("(500, 2)", getGridElement().getCell(500, 0) + .getText()); + Assert.assertEquals("(500, 3)", getGridElement().getCell(500, 1) + .getText()); + + toggleHideColumnAPI(0); + toggleHideColumnAPI(1); + + Assert.assertEquals("(500, 0)", getGridElement().getCell(500, 0) + .getText()); + Assert.assertEquals("(500, 1)", getGridElement().getCell(500, 1) + .getText()); + } + private void loadSpannedCellsFixture() { selectMenuPath("Component", "State", "Width", "1000px"); appendHeaderRow(); |