summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur <artur@vaadin.com>2017-03-07 10:50:13 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-07 10:50:13 +0200
commitcd26b9b32a782b85392a72fdab8eed43731a28d6 (patch)
tree0f7e34424ab5d44c74e533d39925623dee5699e5 /server
parent6a88649a5f56bc99c7870c8a4e4b1f30804bae8b (diff)
downloadvaadin-framework-cd26b9b32a782b85392a72fdab8eed43731a28d6.tar.gz
vaadin-framework-cd26b9b32a782b85392a72fdab8eed43731a28d6.zip
Add missing Grid.removeAllColumns (#8750)
Fixes #8704
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java9
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java14
2 files changed, 23 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 d5d0a30bd1..a9f7f743e3 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2324,6 +2324,15 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
}
/**
+ * Removes all columns from this Grid.
+ */
+ public void removeAllColumns() {
+ for (Column<T, ?> column : getColumns()) {
+ removeColumn(column);
+ }
+ }
+
+ /**
* Sets the details component generator.
*
* @param generator
diff --git a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java
index 40c753943e..c85cf5ee73 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/grid/GridTest.java
@@ -404,6 +404,20 @@ public class GridTest {
}
@Test
+ public void removeAllColumns() {
+ grid.removeAllColumns();
+
+ Assert.assertEquals(Collections.emptyList(), grid.getColumns());
+ }
+
+ @Test
+ public void removeAllColumnsInGridWithoutColumns() {
+ grid.removeAllColumns();
+ grid.removeAllColumns();
+ Assert.assertEquals(Collections.emptyList(), grid.getColumns());
+ }
+
+ @Test
public void setColumns_reorder() {
// Will remove other columns
grid.setColumns("length", "foo");