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.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 2 weeks ago
Using setRowStyleGenerator
I had trouble finding a concrete example of how to use setRowStyleGenerator, so after figuring it out I thought I would share it:
In this example I am looking for a string within a specific column's cell within a row of a grid, then add the class name "red" to the row.
this.setRowStyleGenerator(new RowStyleGenerator() {
public String getStyle(Grid.RowReference row) {
if (row.getItem().getItemProperty("YOUR_COLUMN_NAME").getValue() != null ) {
String testString1 = "my string to find";
Object testObj1 = row.getItem().getItemProperty("YOUR_COLUMN_NAME").getValue();
if (testObj1.toString().contains(testString1)) {
return "red"; //adds class="red" to this row, in css add: .red td {background:red}
}
}
return null;
}
});
Last updated on
Hi,
Thanks for sharing.
There is an exaple in the Book of Vaadin: https://vaadin.com/docs/-/part/framework/components/components-table.html#components.table.css.cellstylegenerator
Last updated on
You cannot reply to this thread.