XML + same ID = attribute not setted

Hi,
i create my tree using XML and I set some attribute, example:

If the id of item is unique there is no problem, but if the id is repeated when I execute tree.getAttribute(my_id, “idPage”) I obtain “undefined”.
I know that if I replicate an id I get an id equals to “id + timestamp” but I expect that the attributes I setted via XML can be get via javascript.

Sorry for my poor English,
Michele

Hi
To reproduce locally we need direct link or completed demo.
docs.dhtmlx.com/doku.php?id=othe … leted_demo
If you have PRO version - please, create ticket in the support system or attach demo in PM

Hi,
you can find a demo.
I have a PRO version, but I think that this problem can help someone other.
If you want I can also open a ticket.

How try the demo:
Every time you click on a tree element I print the attribute “idPage”.
Now open “first page”
open “first section”
open “fourth button”
Now if you click “inner page” (id=“P72”, not unique into the xml-tree) you get “undefined”

Thanks,
Michele

Conditions of the license excluded addition the files of the PRO version on a forum for a free access. Therefore I downloaded your archive and deleted it. Wait for the answer, please.

Sorry for a long delay.
It is impossible to allow ids duplication in building a tree. Check that you haven’t repeated ids.

Hi Dayra,
thanks for reply.
About the problem, I must have the possibility to set more times the same element. My tree is a “tree navigation” where I can have more “homepage” and a page can redirect to a homepage, so that homepage is contained twice into the tree.
I don’t understand why I can’t get an attribute for an element tree that has contained twice or more times into the tree.
I can concatenate the id and all my attributes to obtain an “unique id” and after splitting the “unique id” to get the id and all its attributes. But this is a bad programming :frowning: and I don’t want do this.
Michele

To get attribute you need to use dhtmlxtree_attrs.js extention.

I already use it, you could find it into the “complete demo” (before you removed it from my second post).
If you want I can send the demo in a private message.

Yes, i know.
So, i’ve corrected id P72 at lines 33 & 35:

<item id="P72_" im0="page.png" im1="page.png" im2="page.png" type="P" idPage="72"> <itemtext><![CDATA[<span class="page">page</span>]]></itemtext> <item id="S72" child="P72_" im0="section.png" im1="section.png" im2="section.png" type="S" idPage="72"> <itemtext><![CDATA[<span class="section">section</span>]]></itemtext>
And error disappeared.

About your attribute ‘child’ - you can use method getParentId to get a parent ID if you need it.

Mmmh, I’m sure that you code is correct, but I don’t want to put an underscore character ‘_’ to make an item unique.
If I have the same item three or more times I don’t want to put another and another underscore character to make the elements unique.

I don’t suggest to use to you this symbol. I used it for an example: if IDs are different - there are no mistakes.