簡體   English   中英

SmartGWT:是否可以為列表網格中的某一行着色?

[英]SmartGWT: is it possible to color a a certain row in a list grid?

所有可以在smartGWT listGrid中為某一行着色? 我想只為1行着色,而不是所有listGrid

在SmartGWT中,以Style結尾的方法( 例如,獲取Style,getBaseStyle,getCellStyle等)需要返回在別處定義的CSS類(.css文件,應用程序加載jsp中的內聯css等)。
同樣適用於設置樣式方法。

除非完成大量的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,如上面鏈接的展示示例中所示,除非有其他原因這樣做。

從來沒有使用過SmartGWT,但是看看JavaDoc,我會說:

listGrid.getRecord(recordNum)

也檢出這 ,它覆蓋getBaseStyle()的的ListGrid

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM