calculates the combined start/end dates of tasks nested in a project or another task
task_id | string | number | the task's id, root_id will be used if not specified |
object | an object containing the start_date and end_date properties |
// duration of the whole project
let dates = gantt.getSubtaskDates();
const dateToStr = gantt.templates.task_date;
console.log(`${dateToStr(dates.start_date)} - ${dateToStr(dates.end_date)}`);
// duration of the subproject
dates = gantt.getSubtaskDates(1);
console.log(`${dateToStr(dates.start_date)} - ${dateToStr(dates.end_date)}`);
The method returns an object containing the start date of the earliest subtask and the end date of the latest subtask.
The return object has the following format:
{
start_date: Date|null,
end_date: Date|null
}
If a Gantt chart has any scheduled tasks, both properties will have date values. If the Gantt chart is empty or contains only unscheduled tasks, both properties will have null
values.