[英]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,我会说:
也检出这样 ,它覆盖getBaseStyle()
的的ListGrid
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.