Java SmartGWT:是否可以为列表网格中的某一行着色?

Java SmartGWT:是否可以为列表网格中的某一行着色?,java,gwt,row,smartgwt,listgrid,Java,Gwt,Row,Smartgwt,Listgrid,是否可以在smartGWT listGrid中为某一行着色? 我只想给一行上色,不是所有的listGrid都从来没有使用过SmartGWT,但是看看JavaDoc,我会说: 此外,还请检查此项,它会覆盖SmartGWT中的ListGrid,以样式结尾的方法(例如-getStyle、getBaseStyle、getCellStyle等)需要返回在别处定义的CSS类(.CSS文件、应用程序加载jsp中的内联CSS等)。 同样适用于setStyle方法 除非做了大量的CSS定制来保证这样的需

是否可以在smartGWT listGrid中为某一行着色?
我只想给一行上色,不是所有的listGrid都从来没有使用过SmartGWT,但是看看JavaDoc,我会说:


此外,还请检查此项,它会覆盖SmartGWT中的
ListGrid

,以样式结尾的方法(例如-getStyle、getBaseStyle、getCellStyle等)需要返回在别处定义的CSS类(.CSS文件、应用程序加载jsp中的内联CSS等)。
同样适用于setStyle方法

除非做了大量的CSS定制来保证这样的需求,否则使用可能是最好的选择

getCellCSSText返回每个单元格的CSS文本,并将在每次重画期间调用

final ListGrid resultsGrid = new ListGrid() {
    @Override
    protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
        String style = super.getCellCSSText(record, rowNum, colNum);

        // conditions can check values in record using rowNum, colNum as well as record attributes
        if (record.getAttribute("<grid-field-name>").equals(<value>)) {
            if (this.getFieldName(colNum).equals("<certain-grid-field-name>") && record.getAttribute("<grid-field-name>").equals(<specific-value>)) {
                style = "font-weight:bold"; // only that cell in that row becomes bold
            } else {
                style = "color:red"; // all other cells in that row become red
            }
        } else if (record.getAttribute("<other-grid-field-name>").equals(<value>)) {
            style = "color:green"; // entire row changed to green if one column in this row contain a specific value
        }

        return style;
    }
};
final ListGrid resultsGrid=new ListGrid(){
@凌驾
受保护字符串getCellCSSText(ListGridRecord记录,int rowNum,int colNum){
字符串样式=super.getCellCSSText(记录、行数、列数);
//条件可以使用rowNum、colNum以及记录属性检查记录中的值
if(record.getAttribute(“”.equals()){
if(this.getFieldName(colNum).equals(“”)和record.getAttribute(“”.equals()){
style=“font-weight:bold”//只有该行中的单元格变为粗体
}否则{
style=“color:red”//该行中的所有其他单元格都变为红色
}
}else if(record.getAttribute(“”.equals()){
style=“color:green”;//如果此行中的一列包含特定值,则整行变为绿色
}
回归风格;
}
};

除非有其他原因,否则不需要像上面链接的showcase示例中所示扩展ListGridRecord。

。我想这个链接应该会有帮助you@AbhijithNagaraja,该问题与GWT有关,而与SmartGWT无关。
setCustomStyle()
的问题是,之后您将丢失原始样式。