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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Appending grid column styles (Vaadin8)?
Hi Folks,
Is their any way to append the styles for grid columns in Vaadin 8?. Essentially, I want to do something like this
grid.getColumn("col1").setStyleGenerator( c -> "bold");
grid.getColumn("col1").setStyleGenerator( c -> grid.getColumn("col1").getStyleGenerator() + " red");
This unfortunately, overwrites bold with red and doesn't append. I took a look at StyleGenerator.andThen() but couldn't make it work either
Any help is much appreciated
Hi,
The following should work in order to add the red style name:
StyleGenerator<POJO> s = col.getStyleGenerator();
col.setStyleGenerator( p -> (s.apply(p) + ".red"));
here "col" is a reference to the column.
-Pontus
Thanks to you Pontus, my code is going to get slightly cleaner today
Seems like I came close but didn't think through. As a side note, why not add this to the vaadin grid
grid.addColumnStyle(col1, StyleGenerator s);
It should be a quick change