how to handle background images in grid cell
I have a need to add an image to an editable grid cell based on some critera. When I add the image it appears but when I edit the cell I no longer get the dirty cell image (red triangle in upper left corner). I have tried to add an image two different ways but only one worked? I there a way to add an image and still obtain the dirty cell marker after the edit? If I am not doing this correctly please advise.
Code:
private class CustomGridCellRenderer implements GridCellRenderer<ModelData> {
@Override
public Object render(ModelData model,
String property,
ColumnData config,
int rowIndex,
int colIndex,
ListStore<ModelData> store,
Grid<ModelData> grid) {
Integer baseValue = model.get(property);
Element cell = grid.getView().getCell(rowIndex, colIndex);
if ( cell != null && property != null && property.contains("eqmt") && !property.contains("transcom")){
cell.getStyle().clearProperty("background");
// this didn't work
cell.getStyle().setBackgroundImage("url(../images/default/grid/note.gif)");
// this did
// config.style = "background: transparent no-repeat right top; background-image: url(../images/default/grid/note.gif);";
}
Integer positiveModifierValue = model.get(property + "-positive-modifier");
String cellContents;
if ( positiveModifierValue == null || positiveModifierValue == 0 )
cellContents = baseValue.toString();
else
cellContents = "<span class=\"modified-table-cell\">"
+ baseValue + " ( +" + positiveModifierValue
+ " )</span>";
if ( "0".equals(cellContents) )
cellContents = "";
return cellContents;
}
};