treblereel
18 Apr 2011, 8:26 AM
Hi all, example below works only for the first column, but i need something like this for the several columns.
name.setRenderer(new TreeGridCellRenderer<ModelData>() {
@SuppressWarnings("unchecked")
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store,
Grid<ModelData> grid) {
if(blabla== true){
config.css = "x-treegrid-column-red";
}else{
config.css = "x-treegrid-column-green";
}
assert grid instanceof TreeGrid : "TreeGridCellRenderer can only be used in a TreeGrid";
@SuppressWarnings("rawtypes")
TreeGrid tree = (TreeGrid) grid;
@SuppressWarnings("rawtypes")
TreeStore ts = tree.getTreeStore();
int level = ts.getDepth(model);
String id = getId(tree, model, property, rowIndex, colIndex);
String text = getText(tree, model, property, rowIndex, colIndex);
AbstractImagePrototype icon = calculateIconStyle(tree, model, property, rowIndex, colIndex);
Joint j = calcualteJoint(tree, model, property, rowIndex, colIndex);
return tree.getTreeView().getTemplate(model, id, text, icon, false, j, level - 1);
}
});
name.setRenderer(new TreeGridCellRenderer<ModelData>() {
@SuppressWarnings("unchecked")
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store,
Grid<ModelData> grid) {
if(blabla== true){
config.css = "x-treegrid-column-red";
}else{
config.css = "x-treegrid-column-green";
}
assert grid instanceof TreeGrid : "TreeGridCellRenderer can only be used in a TreeGrid";
@SuppressWarnings("rawtypes")
TreeGrid tree = (TreeGrid) grid;
@SuppressWarnings("rawtypes")
TreeStore ts = tree.getTreeStore();
int level = ts.getDepth(model);
String id = getId(tree, model, property, rowIndex, colIndex);
String text = getText(tree, model, property, rowIndex, colIndex);
AbstractImagePrototype icon = calculateIconStyle(tree, model, property, rowIndex, colIndex);
Joint j = calcualteJoint(tree, model, property, rowIndex, colIndex);
return tree.getTreeView().getTemplate(model, id, text, icon, false, j, level - 1);
}
});