使用 Ext GWT 2,如何根据相似的列值对 Grid 进行着色?
final ColumnConfig colConfig = new ColumnConfig("myProperty", "My Property", 250 );
colConfig.setRenderer( new GridCellRenderer<MyModelModel >() {
@Override
public Object render(
final MyModelModel model,
final String property,
final ColumnData config,
final int rowIndex,
final int colIndex,
final ListStore<MyModelModel> store,
final Grid<MyModelModel> grid) {
final String valueToDisplay = "Some Value";
if( rowIndex % 2 == 0 ) {
config.style = "background-color: pink;";
}
else {
config.style = "background-color: blue;";
}
return valueToDisplay;
}
});
您还可以使用config.css来指定CSS类名。