如何在Vaadin 8中有条件地为网格行着色?
2022-09-04 20:47:51
我想根据单元格的值更改Vaadin网格行的颜色。我尝试了如下,但没有工作。
断续器
@import "mytheme.scss";
@import "addons.scss";
// This file prefixes all rules with the theme name to avoid causing conflicts with other themes.
// The actual styles should be defined in mytheme.scss
.mytheme {
@include addons;
@include mytheme;
.v-grid-row.error_row {
// Tried following elements and didn't work.
// background-color: red !important;
// color: blue !important; // This changed the color of the font.
background: green !important;
}
}
Java Code
grid.setStyleGenerator(t -> {
if (t.getLogLevel().trim().equals(ERROR) || t.getLogLevel().trim().equals(WARN)) {
return "error_row";
} else {
return null;
}
});
注意:我从浏览器的开发人员工具中检查了css,这表明css已正确更新(见下图)。