aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java21
-rw-r--r--server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java5
2 files changed, 23 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 463e475a44..845a61a42a 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -2421,6 +2421,25 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
}
/**
+ * Adds a column that shows components.
+ * <p>
+ * This is a shorthand for {@link #addColum()} with a
+ * {@link ComponentRenderer}.
+ *
+ * @param componentProvider
+ * a value provider that will return a component for the given
+ * item
+ * @return the new column
+ * @param <V>
+ * the column value type, extends component
+ * @since 8.1
+ */
+ public <V extends Component> Column<T, V> addComponentColumn(
+ ValueProvider<T, V> componentProvider) {
+ return addColumn(componentProvider, new ComponentRenderer());
+ }
+
+ /**
* Creates a column instance from a value provider and a renderer.
*
* @param valueProvider
@@ -2428,6 +2447,8 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents,
* @param renderer
* the renderer
* @return a new column instance
+ * @param <V>
+ * the column value type
*
* @since 8.0.3
*/
diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
index 9e6eb33704..d0b2b11dca 100644
--- a/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
+++ b/server/src/test/java/com/vaadin/tests/components/grid/GridComponentRendererTest.java
@@ -15,7 +15,6 @@ import com.vaadin.tests.util.AlwaysLockedVaadinSession;
import com.vaadin.tests.util.MockUI;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Label;
-import com.vaadin.ui.renderers.ComponentRenderer;
/**
* Test to validate clean detaching in Grid with ComponentRenderer.
@@ -37,11 +36,11 @@ public class GridComponentRendererTest {
dataProvider = DataProvider.ofCollection(backend);
grid = new Grid<>();
grid.setDataProvider(dataProvider);
- grid.addColumn(p -> {
+ grid.addComponentColumn(p -> {
oldComponent = testComponent;
testComponent = new Label();
return testComponent;
- }, new ComponentRenderer());
+ });
new MockUI() {
@Override
public Future<Void> access(Runnable runnable) {