How to add different icons for nodes in dhtmlx tree?


Can someone help me with this problem.
I want to add a different node icon (FolderClosed,FolderOpen and Leaf node) for each set of nodes I am adding to the tree. Suppose if I am adding nodes for employee it will have “E” icon. If I am adding project nodes, it will have “P” icon.

Please let me know if this is possible in dhtmlx tree. If so, then please guide me.


I think the setItemImage2 function is what you’re looking for.

Have a look at this page:

But that does not work for me. Whenever I add a new item to the tree how will I know what is the item id to be inserted?

I made a demo for you. I hope it will help you. See the attachment.
tree_icons.rar (51 KB)
One more thing: then you add a node, you use methods insertNewNext() or insertNewChild(). Please, read about them here: … ertnewnext … rtnewchild
There is a description of ‘image1’, ‘image2’ & ‘image3’ parameters.