Ammar8
(Ammar Hassan)
1
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
Pontus2
(Pontus Boström)
2
Hi,
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.
-Pontus
Ammar8
(Ammar Hassan)
3
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