How to add a generated column to a Vaadin 8 grid?

GeneratedPropertyContainer doesn't seem to exist in Vaadin 8.

How to add a generated column in Vaadin 8 Grid? I appreciate if you can give an example.

+6
source share
2 answers

If you pass the bean class to the Grid structure, then it will add all the properties as columns to the grid.

If you want to have only some properties as columns, then do not pass the class to the constructor and manually add your columns:

grid.addColumn(Address::getStreet);
grid.addColumn(Address::getHouseNumber);
grid.addColumn(Address::getPostalCode);
grid.addCOlumn(Address::getCity);

If you want to add the created column just add it using addColumn

grid.addColumn(address -> {
  // put your calculations for the column here
  return address.getStreet() + " " + address.getHouseNumber();
});
+8
source

The generated column will work as follows:

grid.addColumn(address->address.getStreet()+" "+address.getHouseNumber()).setCaption("Street");
0
source

Source: https://habr.com/ru/post/1016372/


All Articles