diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2017-04-12 15:03:17 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-04-12 15:03:17 +0300 |
commit | 2c3e399cb654588c8159e0e4ec4de7cc7de81b7b (patch) | |
tree | d42b862d3e978852a2b7143f3dc94af8730e8169 | |
parent | c1ecea9aa4729b1c8c3d00ebefa1a2a08a352ebf (diff) | |
download | vaadin-framework-2c3e399cb654588c8159e0e4ec4de7cc7de81b7b.tar.gz vaadin-framework-2c3e399cb654588c8159e0e4ec4de7cc7de81b7b.zip |
Fix empty TreeGrid (#9067)
4 files changed, 42 insertions, 1 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java b/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java index 72c4487aaf..b5c11eba1d 100644 --- a/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/treegrid/TreeGridConnector.java @@ -98,7 +98,8 @@ public class TreeGridConnector extends GridConnector { // Id of new hierarchy column. Choose first when nothing explicitly // set String newHierarchyColumnId = getState().hierarchyColumnId; - if (newHierarchyColumnId == null) { + if (newHierarchyColumnId == null + && !getState().columnOrder.isEmpty()) { newHierarchyColumnId = getState().columnOrder.get(0); } @@ -106,6 +107,11 @@ public class TreeGridConnector extends GridConnector { Grid.Column<?, ?> newColumn = getColumn(newHierarchyColumnId); Grid.Column<?, ?> oldColumn = getColumn(oldHierarchyColumnId); + if (newColumn == null && oldColumn == null) { + // No hierarchy column defined + return; + } + // Unwrap renderer of old column if (oldColumn != null && oldColumn.getRenderer() instanceof HierarchyRenderer) { diff --git a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java index fedad9dd55..7580afd241 100644 --- a/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java +++ b/server/src/main/java/com/vaadin/data/provider/HierarchicalDataCommunicator.java @@ -140,6 +140,8 @@ public class HierarchicalDataCommunicator<T> extends DataCommunicator<T> { sendData(0, dataObjects); getActiveDataHandler().addActiveData(items.stream()); getActiveDataHandler().cleanUp(items.stream()); + } else { + getClientRpc().reset(0); } setPushRows(Range.withLength(0, 0)); diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridEmpty.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridEmpty.java new file mode 100644 index 0000000000..362226a69a --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridEmpty.java @@ -0,0 +1,14 @@ +package com.vaadin.tests.components.treegrid; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.TreeGrid; + +public class TreeGridEmpty extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + TreeGrid<String> grid = new TreeGrid<>(); + addComponent(grid); + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridEmptyTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridEmptyTest.java new file mode 100644 index 0000000000..2f0c886916 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridEmptyTest.java @@ -0,0 +1,19 @@ +package com.vaadin.tests.components.treegrid; + +import static org.junit.Assert.assertFalse; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class TreeGridEmptyTest extends SingleBrowserTest { + + @Test + public void empty_treegrid_initialized_correctly() { + setDebug(true); + openTestURL(); + assertNoErrorNotifications(); + assertFalse(isElementPresent(By.className("v-errorindicator"))); + } +} |