XML data format for Collections

I have found an example of how the JSON data for collections should look like here:
https://docs.dhtmlx.com/gantt/desktop__select.html#populatingcontrolwithdatafromtheserver

What about the XML format? I searched the docs but did not find examples. (Also Claude and Grok did not find them)

Grok suggested me this format, but it looks like I can’t get the employees collection values in my ServerList.

Hello @jzzh,

You can define XML collections directly inside your XML using the <coll_options> tag. When you call gantt.parse(xml, "xml"), the library will recognize these options and populate the corresponding serverList automatically.
So your XML data structure could look like this:

<data>
  <task id="10" type="project" text="Project #1" start_date="01-04-2025" duration="18" open="true" progress="0.4" end_date="19-04-2025" />
  <task id="2" text="Task #1" parent="10" start_date="02-04-2025" duration="8" progress="0.6" end_date="10-04-2025" owner_id="2" />
  <task id="3" text="Task #2" parent="10" start_date="11-04-2025" duration="8" progress="0.6" end_date="19-04-2025" owner_id="1" />

  <coll_options for="employees">
     <item key="1" label="Alice" />
     <item key="2" label="Bob" />
  </coll_options>
</data>

And then you can access the list via the gantt.serverList() method:

const employees = gantt.serverList("employees");

This gives you an array like:

[
  { key: "1", label: "Alice" },
  { key: "2", label: "Bob" }
]

Please check the following example: DHTMLX Snippet Tool.

By the way, is there a specific reason why you prefer using XML instead of JSON for collections? JSON is the recommended and more commonly used format in Gantt, so I just want to better understand your use case.

Best regards,
Valeria Ivashkevich
DHTMLX Support Engineer

Thank you Valeria, this is what I was looking for.
Yes I already tried to switch from XML to JSON but had some trouble.
Will probably try to switch again at some point.

I’m using a somewhat outdated Plugin for Oracle APEX framework.
This has XML as main source example to support older Oracle DBs without JSON support.

1 Like

Hello,

Thank you for clarifying about Oracle APEX — that explains the XML use case well. I’m glad I could help.

Best regards,
Valeria Ivashkevich
DHTMLX Support Engineer