diff options
Diffstat (limited to 'server')
3 files changed, 13 insertions, 25 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 3ae03679cf..7e283a38ea 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -1906,6 +1906,16 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, } /** + * Gets the Renderer for this Column. + * + * @return the renderer + * @since + */ + public Renderer<? super V> getRenderer() { + return (Renderer<? super V>) getState().renderer; + } + + /** * Gets the grid that this column belongs to. * * @return the grid that this column belongs to, or <code>null</code> if @@ -4006,7 +4016,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, column = addColumn(id); } else { DeclarativeValueProvider<T> provider = new DeclarativeValueProvider<>(); - column = new Column<>(provider, new HtmlRenderer()); + column = createColumn(provider, new HtmlRenderer()); addColumn(getGeneratedIdentifier(), column); if (id != null) { column.setId(id); diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java index 310a7c6cf5..fdda7226fe 100644 --- a/server/src/main/java/com/vaadin/ui/TreeGrid.java +++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java @@ -486,26 +486,6 @@ public class TreeGrid<T> extends Grid<T> childItem -> writeRow(container, childItem, item, context)); } - @Override - protected <V> Column<T, V> createColumn(ValueProvider<T, V> valueProvider, - AbstractRenderer<? super T, ? super V> renderer) { - return new Column<T, V>(valueProvider, renderer) { - - @Override - public com.vaadin.ui.Grid.Column<T, V> setRenderer( - Renderer<? super V> renderer) { - // Disallow changing renderer for the hierarchy column - if (getInternalIdForColumn(this).equals( - TreeGrid.this.getState(false).hierarchyColumnId)) { - throw new IllegalStateException( - "Changing the renderer of the hierarchy column is not allowed."); - } - - return super.setRenderer(renderer); - } - }; - } - /** * Emit an expand event. * diff --git a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java index 1544a4f69d..1f900688c4 100644 --- a/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java +++ b/server/src/test/java/com/vaadin/tests/components/treegrid/TreeGridTest.java @@ -14,11 +14,10 @@ public class TreeGridTest { private boolean expandEventFired = false; private boolean collapseEventFired = false; - @Test(expected = IllegalStateException.class) public void testChangeRendererOfHierarchyColumn() { treeGrid.addColumn(Object::toString).setId("foo"); treeGrid.setHierarchyColumn("foo"); - // This should not be allowed. + // This should be allowed. treeGrid.getColumn("foo").setRenderer(new TextRenderer()); } @@ -28,8 +27,7 @@ public class TreeGridTest { treeData.addItem(null, "Foo"); treeData.addItem("Foo", "Bar"); treeData.addItem("Foo", "Baz"); - treeGrid.setDataProvider( - new TreeDataProvider<>(treeData)); + treeGrid.setDataProvider(new TreeDataProvider<>(treeData)); treeGrid.addExpandListener(e -> expandEventFired = true); treeGrid.addCollapseListener(e -> collapseEventFired = true); |