aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2020-09-04 13:23:34 +0300
committerGitHub <noreply@github.com>2020-09-04 13:23:34 +0300
commit665f3355a2f6a759ca7ee088025a4546c3953b02 (patch)
treeb0166df139e67730dfc805b183251f033e9d60ac /server/src/main
parent10f7e15da976f2cd9ffd19674121cb1d403ef355 (diff)
downloadvaadin-framework-665f3355a2f6a759ca7ee088025a4546c3953b02.tar.gz
vaadin-framework-665f3355a2f6a759ca7ee088025a4546c3953b02.zip
Add convenience overloading for setColumn (#12093)8.12.0.alpha2
Fixes: https://github.com/vaadin/framework/issues/7773
Diffstat (limited to 'server/src/main')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index bba799690d..eb90328725 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -4020,6 +4020,28 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
.forEach(this::removeColumn);
}
+ /**
+ * Sets the columns and their order based on their column ids provided that
+ * collection supports preserving of the order. Columns currently in this
+ * grid that are not present in the collection of column ids are removed.
+ * This includes any column that has no id. Similarly, any new column in
+ * columns will be added to this grid. New columns can only be added for a
+ * <code>Grid</code> created using {@link Grid#Grid(Class)} or
+ * {@link #withPropertySet(PropertySet)}.
+ *
+ *
+ * @param columnIds
+ * the column ids to set
+ *
+ * @see Column#setId(String)
+ * @see #setColumns(String...)
+ */
+ public void setColumns(Collection<String> columnIds) {
+ Objects.requireNonNull(columnIds, "columnIds can't be null");
+ String[] columns = columnIds.toArray(new String[columnIds.size()]);
+ setColumns(columns);
+ }
+
private String getGeneratedIdentifier() {
String columnId = "" + counter;
counter++;