getSubtaskDates
Description
Calculates the combined start/end dates of tasks nested in a project or another task
getSubtaskDates: (task_id?: string | number) => any
Parameters
task_id- (optional) string | number - the task's id, root_id will be used if not specified
Returns
dates- (object) - an object containing the start_date and end_date properties
Example
// 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)}`);
Details
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.
Related API
Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.