Available only in PRO Edition

Auto Scheduling

This functionality is available only in the PRO edition

Starting from version 3.3, the library provides the ext/dhtmlxgantt_auto_scheduling.js extension that gives Gantt the ability to schedule tasks automatically depending on relations between them.

For example, imagine that you have two tasks connected by a dependency link and the second task starts when the first one ends, and you need to change the schedule of the first task by moving it to a new date.

Auto scheduling makes the start date of the second task update according to the end date of the first task each time when it changes. This feature allows you to generate and maintain project schedule by specifying relations between tasks with no need to set dates of each task manually.

To use the auto scheduling functionality, you should include the dhtmlxgantt_auto_scheduling.js extension on the page:

<script src="../codebase/ext/dhtmlxgantt_auto_scheduling.js"></script>

And set the auto_scheduling property to true:

gantt.config.auto_scheduling = true;

What is more, when auto scheduling is enabled, individual tasks still can be scheduled manually. They are independent of relations between tasks. To disable auto scheduling for a particular task and make it manually scheduled, set the auto_scheduling property of the task object to false:

var task = gantt.getTask(id);
task.auto_scheduling = false;

Related sample:  Auto Scheduling extension

API overview

The list of available methods and properties:

Activation

To enable auto scheduling in the Gantt chart, set the auto_scheduling property to true:

gantt.config.auto_scheduling = true;

Strict mode

By default, tasks are rescheduled only when a new date violates the constraint. In order to always reschedule tasks to the earliest possible date, use the property auto_scheduling_strict:

gantt.config.auto_scheduling_strict = true;

Initial auto-scheduling

The auto_scheduling_initial property specifies whether gantt will do auto scheduling on data loading. It's set to true by default:

gantt.config.auto_scheduling_initial = true;

Recalculating the project

To recalculate the schedule of the whole project, use the autoSchedule method:

gantt.autoSchedule();

If you need to recalculate the schedule starting from a particular task, pass the id of the task as an argument to the autoSchedule method:

gantt.autoSchedule(taskId);

Checking whether a task is unscheduled

In case you need to check whether the task is unscheduled, use the isUnscheduledTask method with the task object as an argument:

var isUnscheduled = gantt.isUnscheduledTask(task);

Search for circular references

To find all circular references in the chart, make use of the findCycles method:

gantt.findCycles();

Checking whether a link is circular

If you need to check whether the link is circular, you can apply the isCircularLink method:

var isCircular = gantt.isCircularLink(link);

Getting connected tasks and links

To get the list of tasks and links a task is connected with, use the getConnectedGroup method:

gantt.getConnectedGroup(18);
// => {links:["16", "17", "18"], tasks:[18, 17, 19, 20]}

The list of events

The list of available events is given below:

// before auto scheduling starts
gantt.attachEvent("onBeforeAutoSchedule",function(taskId){
    // any custom logic here   
    return true;
});
 
// after auto scheduling finishes
gantt.attachEvent("onAfterAutoSchedule",function(taskId, updatedTasks){
    // any custom logic here
});
 
// before a particular task is rescheduled
gantt.attachEvent("onBeforeTaskAutoSchedule",function(task,start,link,predecessor){
    // any custom logic here
    return true;
});
 
// after a particular task is rescheduled
gantt.attachEvent("onAfterTaskAutoSchedule",function(task,start,link,predecessor){
    // any custom logic here
});
 
// if the circular reference has been detected and auto scheduling is not possible
gantt.attachEvent("onCircularLinkError",function(link, group){
    // any custom logic here
});
 
// if circular links were found during auto scheduling
gantt.attachEvent("onAutoScheduleCircularLink",function(groups){
    // any custom logic here
});

Setting lag and lead times between tasks

Lag and lead times are special values that are used to create complex relations between tasks.

Lag is a delay between tasks which are linked by a dependency. Lead is an overlap between tasks which are linked by a dependency.

There can be two types of successor tasks:

  • a task that can start before its predecessor task's end (task B starts before task A is finished)

E.g.: If we set a lead equal to 1 day for the dependency link, task B will start one day before task A ends;

  • a task that can't start until after some delay that follows the finish of its predecessor task (task B starts in some time after task A is finished)

E.g.: If we set a lag equal to 1 day for the dependency link, task B will start in one day after task A ends.

Lag and lead values are set in the additional property of the link object - link.lag:

  • lag - any whole positive value,
  • lead - a negative value of the lag.

By default, it's implied that the lag value of each dependency link is set as 0.

Editing link values from UI

Gantt doesn't provide a built-in UI for editing lag or any other properties of the link. However, you can implement it manually by following the recommendations given in the related chapter.

Related sample:   Edit-lag Popup

Back to top