Skip to content

Commit

Permalink
Fix Grid.addColumn without renderer to accept any type (#7974)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuoanttila authored and ahie committed Dec 14, 2016
1 parent 1e801e5 commit 44b75ed
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server/src/main/java/com/vaadin/ui/Grid.java
Expand Up @@ -79,7 +79,6 @@
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;
Expand Down Expand Up @@ -1869,7 +1868,7 @@ protected void readDesign(Element design, DesignContext designContext) {
/*
* 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.
Expand Down Expand Up @@ -2487,18 +2486,21 @@ public Column<T, String> addColumn(String identifier,
}

/**
* 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
*
* @return the new column
*/
public Column<T, String> addColumn(
SerializableFunction<T, String> valueProvider) {
return addColumn(getGeneratedIdentifier(), valueProvider,
SerializableFunction<T, ?> valueProvider) {
return addColumn(getGeneratedIdentifier(),
t -> String.valueOf(valueProvider.apply(t)),
new TextRenderer());
}

Expand Down

0 comments on commit 44b75ed

Please sign in to comment.