Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bill jindrich on Jul 10, 2008 08:44
open dhtmlx forum
dhtmlXtree: Id's - any limits? any way to define multiple ID's/

A couple questions on the ID attribute for the items in the data XML file:
- Is there any limit to the length of the ID field? Any characters that cannot be used in the ID field?
- Is there any way to define another field to define as a secondary ID field, to help define uniqueness when a page is shared?

Here's what I mean by the second question: in our content model, an HTML page can be shared across multiple items within out tree. We want the tree to be loaded, with the correct item in the tree being highted when the page is loaded.

For example, we have:
page1.html
page2.html
sharedPage.html

and the tree might look like:

Item A (launches page1.html)
Item B (launches sharedPage.html)
Item C (launches page2.html)
Item D (launches sharedPage.html)

No matter which of the 4 items are clicked, we want the correct item in the tree to be highlighted. We're thinking that some type of unique ID parameter must be added in order to distinguish item B from item D, so the URL's might look like this:

Item A (launches page1.html)
Item B (launches sharedPage.html?ID=123)
Item C (launches page2.html)
Item D (launches sharedPage.html?ID=456)

We have javascript to parse of a portion of the querystring and then highlight the matching ID in the tree. I'm just trying to determine the best way to define & manage the unique ID for each item, so that the correct item can always be highlighted in the tree, regardless of whether or not the page is shared or not. Any suggestions for how to define unique ID's in the XML for each type of page and the best way to parse the querystring, in order to always highlight the correct item in the tree would be appreciated.
Answer posted by Support on Jul 10, 2008 09:03
>>- Is there any limit to the length of the ID field?
    Technically there is no limitation ( there are known implementation, where IDs contains more that 100 characters )

>>Any characters that cannot be used in the ID field?
Technically - there is no limitation here as well, but if you plan to serialize tree, the usage of "'&<> characters is not recommended.
"," characters used as list separator, so its usage also may cause some problems
ID == "0", used by super-root item by default, and can't be used by other nodes.

>>- Is there any way to define another field to define as a secondary ID field
No, there is no way to achieve such use-case
as possible workaround you can use complex IDs
    <item id="sharedPage^1" />
    <item id="sharedPage^2" />
In such case id is unique, and it is pretty easy to get meaningful part of ID.  ( var page = id.split("^")[0]  )