I am using a Vaadin grid to display incoming information and update it in realtime. I have been able to style all of the rows by accessing the DOM like so:
<dom-module id="my-grid" theme-for="vaadin-grid">
<template>
<style>
[part="row"] {
height: 27px;
font-size: 14px;
max-height: 27px;
}
</style>
</template>
</dom-module>
What I am trying to do is set specific styling to certain rows based on the contents of the data of the row. Basically I have a column of booleans and if it's true, I want the row to have a green background, and if it's false I want that row to have a red background. Now sure how I would do this in my Java code or my shared-styles.html
. Thank you so much!
I have seen this example for programatically styling a column based on a condition, but not a row..
Grid<Person> grid = new Grid<>();
grid.setItems(people);
grid.addColumn(new ComponentRenderer<>(person -> {
if (person.getGender() == Gender.MALE) {
return new Icon(VaadinIcons.MALE);
} else {
return new Icon(VaadinIcons.FEMALE);
}
})).setHeader("Gender");