Hi all,
let’s say I want to add a Column to my Grid which displays a double and applies a style if the number is negative.
In Vaadin 8 I would implement a StyleGenerator and return a fitting style-name in the String apply(…) method, then link it with setStyleGenerator(…) to the Column.
What are we supposed to do in Vaadin 10?
Use a ComponentRenderer like so?
gr.addColumn(new ComponentRenderer<Span, Person>(person -> {
Span sp = new Span();
sp.setText(String.valueOf(person.getSalary()));
if (person.getSalary() < 0) {
sp.addClassName("value-negative");
} else {
sp.removeClassName("value-negative");
}
return sp;
})).setHeader("Component-Column");
And what about Row-Styles? Would I have to use a ComponentRenderer like above for every single column?