Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin 8: where has Grid.Column.setConverter() gone?

Jean-François Lamy
5 years ago Mar 12, 2017 7:58pm

I need to display and edit numbers with a fixed number of decimals in a grid (and elsewhere).  A localized number field would be nice, but I digress.

For the purpose of editing in place, I had to write a converter, which is fine.  I want numbers to look the same whether in the grid or during editing.  The display of the grid itself does not use the editor converter, and there is no way that I can find to rely on setConverter() as used to be possible in v7 (click on the link!).  Since I already have the converter, and this used to work, maybe I'm just missing something silly.

TextField bodyWeightField = new TextField();
        StringToBodyWeightConverter bodyWeightConverter = new StringToBodyWeightConverter(null, "not a number");
        Column<WeighInAthlete, Float> bwColumn = grid.addColumn(WeighInAthlete::getBodyWeight);
        bwColumn
            .setCaption("Body Weight")
            .setEditorBinding(
                binder.forField(bodyWeightField).withConverter(bodyWeightConverter)
                .bind(WeighInAthlete::getBodyWeight, WeighInAthlete::setBodyWeight));
Tatu Lund
5 years ago Mar 13, 2017 7:50am
Jean-François Lamy
5 years ago Mar 14, 2017 12:16am
C. Bosch
5 years ago Mar 14, 2017 8:33am
Pierre PINON
4 years ago May 29, 2017 12:09pm
Jean-Christophe Fortier
4 years ago May 30, 2017 6:22pm
Pierre PINON
4 years ago May 30, 2017 8:44pm
Henri Sara
4 years ago Jul 21, 2017 10:14am
Moritz Christian
4 years ago Jul 21, 2017 10:34am
Pierre PINON
4 years ago Jul 21, 2017 12:47pm

@Henri Sara
 I don't have the problem anymore since I migrated to the Vaadin 8.1 because we can now provide a ValueProvider + PresentationProvider
=> Grid.addColumn(ValueProvider<T, V> valueProvider, ValueProvider<V, String> presentationProvider)

For my part, the problem is solved

Thanks,