View Full Version : Is it possible to change tree icon when i click on it?

9 Jun 2013, 6:59 PM
is it any way to change the tree icon when i click on it. i use GXT 2.X.

Appreciate for any suggestion.

Colin Alworth
10 Jun 2013, 5:17 AM
Moved to the GXT 2 forums, since it is about GXT 2.

How are you defining the icons for the items already? Listen for the click, modify the data so that the icon changes, and then tell the store that the data has been changed so the item must be redrawn.

10 Jun 2013, 5:54 PM
Tree.setIconProvider(new ModelIconProvider<Data>(){
public AbstractImagePrototype getIcon(Data model){
if (model.hasChildren){
return IconHelper.createPath("./a.gif");
return IconHelper.createPath("./b.gif");

Thank you. I wrote something like these for the tree iron. How can i tell the store to redraw the tree? or you means i need to rebuilt the entire tree again?

Colin Alworth
10 Jun 2013, 8:00 PM
Just like you would to change the text of an item in the tree, or values in a grid (liststore in that case), make the change in the model so that hasChildren is true, and run store.update(model). This notifies any data widgets that are listening that the model passed in has changed, and should be redrawn.