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


The following should work in order to add the red style name:

StyleGenerator s = col.getStyleGenerator();
col.setStyleGenerator( p → (s.apply(p) + “.red”));

here “col” is a reference to the column.

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