Categories | Question details Back To List | ||
Adding/accessing attributes to each item in a tree. Hi, I have a XML of the form <item text="Lawrence Block" id="lb" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="1" attr2="2" attr3="3"> <item text="All the Flowers Are Dying" id="lb_1" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="a1" attr2="a2" attr3="a3"/> <item text="The Burglar on the Prowl" id="lb_2" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="b1" attr2="b2" attr3="b3"/> <item text="The Plot Thickens" id="lb_3" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="c1" attr2="c2" attr3="c3"/> <item text="Grifter's Game" id="lb_4" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="1" attr2="2" attr3="3"/> <item text="The Burglar was Bogart" id="lb_5" im0="leaf.gif" im1="leaves.gif" im2="leaf.gif" attr1="1" attr2="2" attr3="3"/> </item> 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 Answer posted by Support on Mar 10, 2008 06:14 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 |