gantt icon indicating copy to clipboard operation
gantt copied to clipboard

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

Open globdug opened this issue 1 year ago • 1 comments

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

globdug avatar Jun 11 '24 12:06 globdug

@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

gearcoded avatar Jun 27 '24 07:06 gearcoded