2016-06-07 65 views
1

我想更改我的网格的列颜色。不幸的是没有任何反应...这里是我的代码:Vaadin,更改网格列颜色

grid.setCellStyleGenerator((Grid.CellReference cellReference) -> { 
      if ("name".equals(cellReference.getPropertyId())) { 
       return "highlight-green"; 
      } else { 
       return "rightAligned"; 
      } 
     }); 

mytheme.scss:

@import "../valo/valo.scss"; 

@mixin mytheme { 
    @include valo; 

    // Insert your own theme rules here 

    .rightAligned { 
     text-align: right; 
    } 

.v-table-row.v-table-row-highlight-green, 
.v-table-row-odd.v-table-row-highlight-green { 
     background-color: #00ff00; 
    } 
} 

rightAligned的伟大工程,但highlight-green

+1

Firefox没有为[检查CSS(https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_and_edit_CSS)作风问题的非常出色。您可以使用内置的开发者工具来检查为什么你的风格被覆盖(如果有的话),甚至在客户端进行测试添加/更改样式。 –

+1

'v表-row'和'v表行-odd'为Vaadin表,网格组件使用其他样式类'V-网格row'和'V-网格行stripe'。 –

回答

0

尝试添加background-color: #00ff00 !important;

看起来你需要重写框架的现有样式,!important必须帮助。

+0

当我为我的主题添加样式时,'!important'不是必需的。优先级由@ @ mixin开头的'@ include' valo主题控制。 –

+0

你可以创建jsfiddle吗?因此,为您的案例找到解决方案会更容易。 –

+0

让我们等待来自OP的反馈。 –