DHTMLX / gantt

GPL version of Javascript Gantt Chart
https://dhtmlx.com/docs/products/dhtmlxGantt/
GNU General Public License v2.0
1.44k stars 320 forks source link

Error: Invalid tasks tree. Cyclic reference has been detected on task 0 if id=0 #117

Open globdug opened 3 months ago

globdug commented 3 months ago

Hello, I'm trying to import data from XML exported from MS Project.

Project's tasks ID start from 0, but if task ID is equal to 0 in the JSON file then I got the error "Error: Invalid tasks tree. Cyclic reference has been detected on task 0".

Is this a bug or an expected beheaviour?

Best regards, Emanuele

gearcoded commented 2 months ago

@globdug, Usually, the cyclic tree error means that the task has equal id and parent parameters or some child task is listed as the parent task: https://docs.dhtmlx.com/gantt/faq.html#cyclicreferenceerror

However, in DHTMLX Gantt there is an invisible root task that is a parent of all tasks on the root level. So, when you add a task with the 0 ID, it is assigned to the invisible root task, and its parent value becomes 0. So, it creates the cyclic tree.

To have a task with the 0 ID, you need to change the root_id config: https://docs.dhtmlx.com/gantt/api__gantt_root_id_config.html

Here is an example in the snippet: https://snippet.dhtmlx.com/vle0qtkd