中的一个单元格将整个网格行着色。 。 我根据单元格的值着色一列,但我想在gxt网格中为整个行着色(意味着单元格包含的行)帮助我 这里是我对单元格着色的代码(我想为行着色而不是细胞)GXT-根据行
/*------------Coloring Area------------*/
GridCellRenderer<BeanModelType> ColoredGrid = new GridCellRenderer<BeanModelType>() {
@Override
public Object render(BeanModelType model,
String property, ColumnData config,
int rowIndex, int colIndex,
ListStore<BeanModelType> store,
Grid<BeanModelType> grid) {
String valueOfCell = model.get(property);
String style = valueOfCell.equals("Book") ? "GREEN":
valueOfCell.equals("Ersr") ? "red":
valueOfCell.equals("Pen") ? "yellow":
valueOfCell.equals("comp") ? "blue": "";
//Config is the cell and we are setting style here
config.style ="background-color:"+style;
return valueOfCell;
}
};
System.out.println("COLORRRRR "+cleanColoredGrid.toString());
column.setRenderer(ColoredGrid);
/*-------------Coloring Area Ends-------*/
configs.add(column);
谢谢Denu。 。 。非常感谢它的工作。我宣布风格作为全局变量,并在第一列中调用方法,然后风格值(背景颜色)是在字符串(风格),然后我创建了一个新的方法,并给'config.style = style'。 。 ..。 – Amith 2012-01-21 05:01:11
我很高兴你能使它运行。如果您将我的答案标记为“已接受”,我将不胜感激 - 当然,如果您认为我已经带领您朝着正确的方向发展): – denu 2012-03-19 07:10:51