Show tasks even if parent id dont exist

Hello. Lets say we are having gros of id 07123,07456.now if a operation/task is created with parent id assigned as say 01224 , then obviously task will not be visible. But i want that task to be visible. How can i do it? Thank you

Hello,

To make a task visible even if its parent ID is assigned to a non-existent task, you can modify the parent property during task loading in the Gantt chart using the onTaskLoading event:

gantt.attachEvent("onTaskLoading", (task) => {
    if (task.parent != '0' && !gantt.isTaskExists(task.parent)) {
        task.originalParentId = task.parent;
        task.parent = '0';
    }
    
    return true;
});

If the parent task does not exist, it sets the parent property to 0 (root level) and stores the original parent ID in the originalParentId property for future reference.

Here is an example: DHTMLX Snippet Tool

Please note that modifying the parent property during task loading may introduce discrepancies between the Gantt chart and the underlying data source (e.g., database). It is important to carefully manage the synchronization between the chart and the data source to avoid any inconsistencies.