如何将样式应用于特定的Cell表行?

时间:2015-04-06 11:40:42

标签: java css gwt

我想根据某些条件将背景颜色应用于特定的单元格表行元素,我找到了一种API方法  getRowElement(rowNo).getStyle().setBackgroundColor

public void setRowStyleCell(final int rowNo){
    getRowElement(rowNo).getStyle().setBackgroundColor(style);
}

但它没有采用这种样式,因为已经应用于此单元格表的某些其他样式(伪代码样式)(具有高优先级)。

tr:nth-child(odd){background:none !important;}

tr:nth-child(even) {background:none !important;}

有没有办法在gwt中覆盖这个样式?

1 个答案:

答案 0 :(得分:0)

覆盖getCellStuleNames并返回所需的样式。

TextColumn nameColumn = new TextColumn(){

            @Override
           public String getCellStyleNames(Context context, Object  object) {
                 return "styleName"; //The name of style id
             }  

            @Override
            public String  getValue(Object object) {                                         
                return object.getName();
            }           

          };