From 44b75ed4b1bedb385d3995909136309d5f8a2e3b Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Wed, 14 Dec 2016 12:38:31 +0200 Subject: [PATCH] Fix Grid.addColumn without renderer to accept any type (#7974) Closes vaadin/framework8-issues#500 --- server/src/main/java/com/vaadin/ui/Grid.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 60bd9abcaf..11dfb464b9 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -79,7 +79,6 @@ import com.vaadin.shared.ui.grid.HeightMode; import com.vaadin.shared.ui.grid.SectionState; import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.Grid.FooterRow; -import com.vaadin.ui.Grid.SelectionMode; import com.vaadin.ui.components.grid.AbstractSelectionModel; import com.vaadin.ui.components.grid.EditorImpl; import com.vaadin.ui.components.grid.Footer; @@ -1869,7 +1868,7 @@ public class Grid extends AbstractListing /* * This is a fake editor just to have something (otherwise * "setEditable" throws an exception. - * + * * Let's use TextField here because we support only Strings as * inline data type. It will work incorrectly for other types * but we don't support them anyway. @@ -2487,9 +2486,11 @@ public class Grid extends AbstractListing } /** - * Adds a new text column to this {@link Grid} with string value provider. - * The column will use a {@link TextRenderer}. Identifier for the column is - * generated automatically. + * Adds a new text column to this {@link Grid} with a value provider. The + * column will use a {@link TextRenderer}. The value is converted to a + * String using {@link Object#toString()}. Sorting in memory is executed by + * comparing the String values. Identifier for the column is generated + * automatically. * * @param valueProvider * the value provider @@ -2497,8 +2498,9 @@ public class Grid extends AbstractListing * @return the new column */ public Column addColumn( - SerializableFunction valueProvider) { - return addColumn(getGeneratedIdentifier(), valueProvider, + SerializableFunction valueProvider) { + return addColumn(getGeneratedIdentifier(), + t -> String.valueOf(valueProvider.apply(t)), new TextRenderer()); } -- 2.39.5