PDA

View Full Version : TreeGrid text style



_sandro_
12 Dec 2011, 10:06 AM
Hi everybody.

Using a TreeGrid, how can i change the style of text (that appear near the tree icon) in the TreeGrid, only for some rows? I know it is possible to change the text style in the other columns of the associated grid implementing a GridCellRenderer interface and overriding the render method, but i don't find a similar solution with the class TreeGridCellRenderer.

Thanks.

Quartilan
12 Dec 2011, 11:27 PM
You can use the WidgetTreeGridCellRenderer for the first column. Then you can still determine if you wan't the style of the text to be changed.

example:
private final WidgetTreeGridCellRenderer<Folder> renderer = new WidgetTreeGridCellRenderer<Folder>() {

@SuppressWarnings("unchecked")
@Override
public Widget getWidget(Folder model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore<Folder> store, Grid<Folder> grid) {

String style = model.get(property) == true ? "color: red" : "color:blue";


final StringBuilder html = new StringBuilder("<div style='" + style + "'>" + 10 + "</div>);
final Html l = new Html(html.toString());
return l;
}
};

lindajacquelyn
13 Dec 2011, 2:22 AM
that's really an interesting topic to talk about and please give more suggestions

Quartilan
13 Dec 2011, 2:38 AM
what do you need? Or is this yet another bot? :-)

_sandro_
13 Dec 2011, 3:26 AM
Thank you, the solution code you proposed here works fine!

Sandro