Please see example above - task type that is project, without any children shows a random date, even though start_date is set on the task object.
How can I override this?
I know that it’s supposed to take it from the children, but is there a way to override this and fallback to start_date defined on the project task itself?
If the project task has no children, its start date is set as the first date of the Gantt chart (the min date that tasks are displayed in the chart from) plus the empty interval, which equals to 1 duration_unit. And the duration of the project becomes equal to the duration_step: duration_unit Gantt Docs ; duration_step Gantt Docs ;
If you want to have a project task without children, as a workaround, you can add a task with the task type and make it look like the project task.
Please check the example of how it might be implemented: DHTMLX Snippet Tool ;
Is there no way built in way to override/hook into the function that sets the project start date? Do you have any suggestions on how this could be accomplished?
We have multiple projects user is importing with different start dates but no children. We do want to preserve them as projects but display the correct dates on them.
Is there no way built in way to override/hook into the function that sets the project start date?
Unfortunately, there is no way to change how Gantt calculates the project tasks logic.
Do you have any suggestions on how this could be accomplished?
As a workaround, you can change the type of the task when you parse/load your data into Gantt. You can use onParse or onLoadEnd handlers to iterate over the required data and apply the task type to the project tasks without children: onParse Gantt Docs ; onLoadEnd Gantt Docs ;
You can iterate over the data by eachTask method: eachTask Gantt Docs ;
But you need to replace the type of tasks back when you will export the data from Gantt.
Please check the following example: DHTMLX Snippet Tool ;