getConstraintLimitations

returns the earliest and latest dates allowed by the constraint applied to a task

object getConstraintLimitations(Task task);
taskTaska task object
objectan object containing constraint dates

Available only in PRO Edition

Example

gantt.addTaskLayer(function draw_deadline(task) {
  const constraintType = gantt.getConstraintType(task);
  const types = gantt.config.constraint_types;
  if (constraintType != types.ASAP && 
      constraintType != types.ALAP && task.constraint_date) {
 
    const dates = gantt.getConstraintLimitations(task);
 
    const els = document.createElement("div");
 
    if (dates.earliestStart) {
      els.appendChild(renderDiv(
        task, 
        dates.earliestStart, 
        'constraint-marker earliest-start'
      ));
    }
 
    if (dates.latestEnd) {
      els.appendChild(renderDiv(
        task, 
        dates.latestEnd, 
        'constraint-marker latest-end'
      ));
    }
 
    if (els.children.length)
      return els;
  }
  return false;
});
 
function renderDiv(task, date, className) {
  const el = document.createElement('div');
  el.className = className;
  const sizes = gantt.getTaskPosition(task, date);
  el.style.left = sizes.left + 'px';
  el.style.top = sizes.top + 'px';
  return el;
}

Related samples

Details

This functionality is available in the PRO edition only.

The return value has the following structure:

{
    earliestStart: Date || null,
    earliestEnd: Date || null,
    latestStart: Date || null,
    latestEnd: Date || null
}
See also
Back to top