Dhtmlx tree on load set image


I want to change the image icons for all nodes when the tree loads according to the level. I tried setOnOpenHandler but it changes only while opening a node. Is there any way to loop over all nodes & setItemImage2 over all ids on load? I hope I am clear.

Thanks a lot.

You can use onXLE event, which provides id, for which XML was loaded

var ids = tree.getSubItems(id).split(",")
for ( var i=0; i< ids.length; i++)
tree.setItemImage2(ids[i], some_image);