Hello, I’m using Vaadin 24 and Flow
I’m trying to change the color of a cell if the content match a criteria.
I tried by using .setClassNameGenerator(), like this
this.treeGrid.setClassNameGenerator(item -> {
if (item.varName != null && item.varName.startsWith("[") && item.varName.endsWith("]"))
return "highlighted";
return null;
});
And added the class in my styles.css
.highlighted {
background: red;
}
But it doesn’t work.
I checked through Inspect Element, and I do have cases where it highlighted is applied
<td id="vaadin-grid-cell-79" role="gridcell" tabindex="-1" part="cell body-cell odd-row-cell expanded-row-cell drag-disabled-row-cell drop-disabled-row-cell" style="width: 15%; flex-grow: 0; order: 20000000;" class="highlighted"><slot name="vaadin-grid-cell-content-79"></slot></td>
I am able to change the color of all cells, like this
vaadin-grid::part(cell){
background: red !important;
}
But cannot find how to change if it matches a criteria
I tried multiple ways like:
vaadin-grid::part(cell) .highlighted {
background: red !important;
}
vaadin-grid[class="highlighted"]::part(cell) {
background: red !important;
}
.highlighted::part(cell) {
background: red !important;
}
.highlighted {
background: red;
}
But none of it worked