Programmatically Change Duration

I’m trying to programmatically change the start date and duration of a Task based on creating a Link between two tasks.

When I do the following:

var targetTask = gantt.getTask(; targetTask.start_date = nextDay; targetTask.duration = 6; gantt.updateTask(;

The start_date is changed on the grid and the task bar is moved. The duration changes on the grid, but the task bar’s duration does not change.

Is there another way of performing a duration change?

Appears the easiest way to handle this is to just set the end_date parameter. Duration appears to be more of a grid display setting after initial task create than an editable setting to move the task.

the method for recalculating end_date/duration is missing from gantt public api, sorry for the inconvenience.
If you use the latest beta v2.1 from here download/file.php?id=7445, you can call internal method gantt._init_task_timing(task);
If end_date of the task is specified, the duration will be calculated. If task have only start_date and duration, the method will assign the end_date.

In the version 2.0(which older then beta, and available in, you can call gantt._update_task_duration(task)
We’ll add a proper method to the public api in the upcoming version

I put a custom fields for linking the task, I want to set newly added task date should be just after it’s linked task. And I want duration for this newly linked task should be set by onclick on other button. Can you please help me ?