中的一個單元格將整個網格行着色。 。 我根據單元格的值着色一列,但我想在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