Adding/accessing attributes to each item in a tree

Hi,

I have a XML of the form



















I need to add few attributes in each child node of the tree. The above XML contains attributes (attr1, attr2, and attr3) which I have added to item



I want to know that how could I access the value of these attribute when I select any of the items.

Like there are function present



tree.getItemText(id);

tree.getItemColor(id);

tree.getItemImage(id);



So do we have a function where I can say item.getAttributeValue(“Attribute Name”) and it returns me the value of the attribute when name is supplied as input.

Please suggest me a workaround to do this.



Thanks

In current version tree doesn’t store not used attributes, so it not possible to access them after XML loading.
Behaviour can be changed with single code line modification, you can locate next line in dhtmlxtree.js ( line 900 in latest codebase)

    newNode.span.parentNode.parentNode.title=a.tooltip;

and update it as

    newNode.span.parentNode.parentNode.title=a.tooltip;
    newNode.attrs=a;

after that you will be able to access any attribute mentioned in XML as

    tree._idpull[ID].attrs[name]

where
    ID - item id
    name - name of attribute