java – SmartGWT:是否可以为列表网格中的某一行着色?
发布时间:2020-12-15 05:00:37  所属栏目:Java  来源:网络整理 
            导读:所有可以在smartGWT listGrid中为某一行着色? 我想只为1行着色,而不是所有listGrid 解决方法 在SmartGWT中,以Style结尾的方法(例如getStyle,getBaseStyle,getCellStyle等)需要返回在别处定义的CSS类(.css文件,应用程序加载jsp中的内联css等). 同样适用于set
                
                
                
            | 
 所有可以在smartGWT listGrid中为某一行着色? 
  我想只为1行着色,而不是所有listGrid 解决方法
 在SmartGWT中,以Style结尾的方法(例如getStyle,getBaseStyle,getCellStyle等)需要返回在别处定义的CSS类(.css文件,应用程序加载jsp中的内联css等). 
  同样适用于setStyle方法. 除非完成大量的CSS自定义以保证需要,否则使用getCellCSSText可能是最佳选择. 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;
    }
};它不需要扩展ListGridRecord,如上面链接的展示示例中所示,除非有其他原因这样做. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
