热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在Vaadin8中有条件地为网格行着色?

如何解决《如何在Vaadin8中有条件地为网格行着色?》经验,为你挑选了1个好方法。

我想根据单元格的值更改Vaadin网格行的颜色.我尝试了如下,但没有奏效.

SCSS

@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代码

grid.setStyleGenerator(t -> {
            if (t.getLogLevel().trim().equals(ERROR) || t.getLogLevel().trim().equals(WARN)) {
                return "error_row";
            } else {
                return null;
            }
        });

注意:我从浏览器的开发人员工具中检查css,并显示css已正确更新(请参见下图).

在此输入图像描述



1> Steffen Harb..:

你需要覆盖background-color行的TD元素:

.v-grid-row.error_row > td {
    background-color: red;
}

通过使用浏览器的样式检查,您可以看到Vaadin如何实现样式.


推荐阅读
author-avatar
2yuheng
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有