PDA

View Full Version : GXT 3.0 Tree - How to display custom icon per tree node?



DavidHoffer
20 Dec 2011, 11:28 AM
I need to display a multi-level tree and show various icons per tree node. In the demo examples all I see are images set at the root tree level, i.e. one TreeStyle for the entire tree. How can I display different icons at each of the tree nodes/levels?

dierp
20 Dec 2011, 4:59 PM
Looks like you need to implement an IconProvider and pass it to the Tree.

raivis
21 Dec 2011, 3:54 AM
tree.setIconProvider(new IconProvider<SideMenuDto>() {


@Override
public ImageResource getIcon(SideMenuDto p_model) {
return .... // your icon choosing algorithm
}
});


where SideMenuDto is my tree item object. Use your own in your case.

DavidHoffer
21 Dec 2011, 10:51 AM
Yeah that works perfectly, plus I found I can dynamically update the icons which is what I need to do by calling refresh on the tree. Thanks.