Vaadin 8 - howto format/convert Grid columns

Hi,
I’m trying to build an application with Vaadin 8 and I need to format a frequency value stored as a Long to kHz, MHz or GHz in a Grid column.
eg.: 760000000 = 760 MHz, 500500 = 500.5 kHz, etc…
What is the proper way to format a column like this? My plan was to write a Converter implementation, but there is no setConverter on columns in Vaadin 8.

Hi Gergely,

take a look at the Vaadin 8 Docs for the Grid.


https://vaadin.com/docs/-/part/framework/components/components-grid.html#components.grid.renderer

You can use a NumberRenderer, or even write your own renderer for your specific case.

// the type of birthYear is a number 
Column<Integer> birthYear = grid.addColumn(Person::getBirthYear,
      new NumberRenderer(new DecimalFormat("in #### AD")));