Ext Gantt: Defining Task Constraints

When working with tasks in a large project schedule, some tasks usually have date constraints attached to them. These constraints define strict rules for when a task can start or end. For example, Santa Claus must finish delivering all gifts before end of Christmas (a Finish-No-Later-Than constraint).

Constraint Types

Ext Gantt supports six types of task constraints:

  • * Must-Start-On (alias ‘muststarton’)
  • * Must-Finish-On (alias ‘mustfinishon’)
  • * Start-No-Earlier-Than (alias ‘startnoearlierthan’)
  • * Start-No-Later-Than (alias ‘startnolaterthan’)
  • * Finish-No-Earlier-Than (alias ‘finishnoearlierthan’)
  • * Finish-No-Later-Than (alias ‘finishnolaterthan’)

Each of the constraints listed above is defined by a type (a string) and a target date. Therefore, two new fields have been added to the Task model class – “ConstraintType” and “ConstraintDate“. In your data, you simply set these two fields to define your task constraints. Example task with a “Must-Start-On” constraint:

As you see, the constraint is defined and “satisfied” since the task starts on the same date as the constraint date. To let your users define and change constraints, simply include the two constraint columns and enable cell editing.

Screen Shot 2014-11-07 at 12.37.52

Now if the user modifies a constraint, or the task start date, end date or duration – a prompt will be shown presenting the user with the following options:

* Cancel the change and do nothing
* Remove the constraint
* Move the task to satisfy the constraint

constraint1

If the user checks the “Don’t ask again” checkbox and hits the Ok-button, the same action will be applied to all future constraints violations. (Note: This flag is not persisted during page reloads).

Using the Task Constraints API

You can of course also change a constraint manually using the Task API. If a constraint is violated by your change, the constraint resolution window will popup to allow the user to take the correct action.

The constraint information can also be edited in the TaskEditor window, under the Advanced tab.

API details and asynchronous behavior

Constraints verification is now built-in into the Gantt data layer. Regular methods that affect the start or end date of a task (like setStartDate/setDuration etc) now check for possible constraint conflicts and allow a user to resolve them. Since receving user input to such a conflict resolution is not synchronous, all such methods has been made asynchronous in the general case. These methods all accept a callback, which will be called after all the changes caused by the method has completed. This also includes changes in the positions of any dependent tasks. If constraints are not used, all methods remain synchronous so backward compatibility is fully preserved.

Every time a constraint conflict happens, a constraintconflict event is fired by the task store.

Summing up…

This has been a basic intro to constraints, though there is much more details if you need advanced features. You can define own constraint types too and define how they should restrict the task. For more information, please see the API documentation. Happy hacking!

Leave a Comment