我正在努力为我的GWT 2.4 DataGrid添加样式,但每一步都遇到了阻碍。我已经为我的DataGrid添加了以下行样式:
dataTable.setRowStyles(new RowStyles<IntegrityItem>() {
@Override
public String getStyleNames(IntegrityItem row, int rowIndex) {
if (row.getSomeValue() >= 100) {
return MyResources.INSTANCE.mystyles().alertRow();
} else {
return "";
}
}
});
样式alertRow只是这个样子:
.alertEntry {
font-weight: bold;
color: #00ff00;
background-color: #ff0000;
}
更多信息:我已经制作了DataGrid.css的本地副本,并从所有样式中删除了所有“background”元素,然后我使用它来构建ClientBundle:
public interface MyDataGridResources extends DataGrid.Resources {
public static final FmeaDataGridResources INSTANCE = GWT.create(MyDataGridResources.class);
@Override
@Source({"../resources/styling/mydatagridstyles.css"})
Style dataGridStyle();
}
我在我的DataGrid构造函数中使用了这个(MyDataGridResources.INSTANCE)。
当我尝试它时,符合条件的行包含绿色(#00ff00)文本,但背景颜色仍然是白色或灰色,具体取决于它是偶数行还是奇数行。为什么背景颜色会被忽略呢?首先,它从哪里获取这些颜色?!我已经完全从css文件中删除了背景颜色信息。
dataGrid = new DataGrid<T>(pageSize, resource)
,如何为UIBinder设置CSS资源? - Cataclysm