From f4bbe480693918a9b67f09773b9de03de7b61bd8 Mon Sep 17 00:00:00 2001 From: Aleksi Hietanen Date: Thu, 11 May 2017 08:50:49 +0300 Subject: [PATCH] Add setHierarchyColumn(column) overload to TreeGrid --- .../src/main/java/com/vaadin/ui/TreeGrid.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/src/main/java/com/vaadin/ui/TreeGrid.java b/server/src/main/java/com/vaadin/ui/TreeGrid.java index 1b051d1da6..a6b0fecce5 100644 --- a/server/src/main/java/com/vaadin/ui/TreeGrid.java +++ b/server/src/main/java/com/vaadin/ui/TreeGrid.java @@ -136,6 +136,30 @@ public class TreeGrid extends Grid super.setDataProvider(dataProvider); } + /** + * Set the column that displays the hierarchy of this grid's data. By + * default the hierarchy will be displayed in the first column. + *

+ * Setting a hierarchy column by calling this method also sets the column to + * be visible and not hidable. + *

+ * Note: Changing the Renderer of the hierarchy column is + * not supported. + * + * @param column + * the column to use for displaying hierarchy + */ + public void setHierarchyColumn(Column column) { + Objects.requireNonNull(column, "column may not be null"); + if (!getColumns().contains(column)) { + throw new IllegalArgumentException( + "Given column is not a column of this TreeGrid"); + } + column.setHidden(false); + column.setHidable(false); + getState().hierarchyColumnId = getInternalIdForColumn(column); + } + /** * Set the column that displays the hierarchy of this grid's data. By * default the hierarchy will be displayed in the first column. -- 2.39.5