Color generation for tree nodes in random manner

hello,
I have a tree now Now by default when I click on node its yellow in color.I want the nodes to be colored with different colors when I click on it.The colors should be generated randomly.Please help.
vidhya

Hello,

you may try to use the following method:

tree.attachEvent(“onClick”,function(id,pid){
var item = this._idpull[id];
/your may define the background-color here/
item.span.style.cssText = “background-color:”+your_color;

/previous selected item/
var prevItem = this._idpull[pid];
prevItem.span.style.cssText = “background-color:white”;
})

hello alexandra,
The function you have provided works for the previous item.But the item which i click does not get colored.

The function you have provided works for the previous item.But the item which i click does not get colored.

How do you set item color? I’ve just shown which property can be used to set color. You need to apply own method to set random color:

" item.span.style.cssText = “background-color:” + color_here;";

I changed the event to Oncheck and it worked fine…Thanx.