SmartGWT:是否可以为列表网格中的某一行着色?
所有可以在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("").equals()) { if (this.getFieldName(colNum).equals("") && record.getAttribute("").equals()) { 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("").equals()) { 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)
-
setCustomStyle(String customStyle)
-
setAttribute(String property, BaseClass value)
还要检查此示例 ,该示例将覆盖getBaseStyle()
。