@@ -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) { |
@@ -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)); |
@@ -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); | |||
} | |||
} |
@@ -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"))); | |||
} | |||
} |