SmartGWT:是否可以在列表网格中为某一行着色? [英] SmartGWT: is it possible to color a a certain row in a list grid?

查看:120
本文介绍了SmartGWT:是否可以在列表网格中为某一行着色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有可以在smartGWT listGrid中为某个行着色?
i只想为1行着色,而不是所有的listGrid

all is it possible to color a certain Row in smartGWT listGrid ? i want to color just 1 row , not all the listGrid

推荐答案

在SmartGWT中,以Style - get Style,getBaseStyle,getCellStyle等)需要返回其他地方定义的CSS类(.css文件,应用程序加载jsp中的内联css等)。

同样适用于set
样式方法。

In SmartGWT, methods that end with Style (e.g.- getStyle, getBaseStyle, getCellStyle, etc.) need to return a CSS class defined elsewhere (.css file, inline css in application load jsp, etc.).
Same applies for set
Style methods.

除非大量的CSS自定义已经完成,否则需要使用 getCellCSSText 可能是最好的选择。

Unless lot of CSS customizations are done warranting the need for such, using getCellCSSText would probably be the best option.

getCellCSSText返回每个单元格的CSS文本,并且在每次重绘时都会调用它。

getCellCSSText returns CSS text per cell, and will be called during every redraw.

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,如上面链接的showcase示例所示,除非有其他原因要做所以。

Its not required to extend ListGridRecord as indicated in showcase sample linked above, unless there are other reasons to do so.

这篇关于SmartGWT:是否可以在列表网格中为某一行着色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆