Our state of the art Gantt chart


Post by peter4ef »

Hello,

I ran into some issues with the DateConstraint feature. This issue appears in both the Gantt and the SchedulerPro. And it is reproducable in the basic Gantt demo.

In the basic react demo, I added the following to the ganttConfig:

getDateConstraints: (taskRecord) => {
        console.log("gantt getDateConstraints");
        return {
            start:  new Date(2018,1,20),
            end: new Date(2019,1,20),
        };
      },
  • When task B is pushed forwards because of a dependency from task A to task B when task A is moved by the user, no validation is done on the date constraint for task B, only on the task that is directly being moved.

  • If the task edit is opened, and the start or end date is changed in the edit form, the date constraint is not applied.

  • As a workaround for the previous point, we added a maximum value for the end date of a task on opening the task editor, but the validation does not take place if you type in the date, and immediately press save. The validation only takes place if you click outside of the edit after typing. I also could not find a beforeSave event we could use to force a validation.

The code for setting the min/max dates in the task edit:

taskEditFeature:{
...
listeners: {
  beforeShow({ source }) {
    if (source.loadedRecord?.nextDependencyStartDate) {
      source.widgetMap.endDate.max = source.loadedRecord.nextDependencyStartDate;
    }
    if (source.loadedRecord?.prevDependencyStartDate) {
      source.widgetMap.startDate.min = source.loadedRecord.prevDependencyStartDate;
    }
  },
  }

Is there a better way to use this feature? We have some constraints that are loaded from the server, that the user really should not be able to overwrite in any case.


Post by ghulam.ghous »

Hi there,

getDateConstraints method is only called when a task is resized using drag or moved by dragging as mentioned in our docs:

Returns dates that will constrain resize and drag operations. The method will be called with the task being dragged.

https://bryntum.com/products/gantt/docs/api/Gantt/view/GanttBase#config-getDateConstraints

You can use beforeTaskSave event to apply validations.
https://bryntum.com/products/gantt/docs/api/Gantt/feature/TaskEdit#event-beforeTaskSave

Regards,
Ghous


Post by peter4ef »

Thanks for the info, adding both a min and max date in the task editor beforeShow, and combining it with a beforeTaskSave did the trick.

I believe there is still a situation surrounding weekends where the tasks is resized because of a weekend after dragging and dropping it, where the dateconstraint also does not apply, and the other mentioned issue with a task shifting because of a dependency also still occurs, but I will have to look further into that first. They might also be solved by different events.


Post by ghulam.ghous »

Hi peret4ef,

Glad the event helped you achieve what you were looking for! Can you please share a clip or steps on how to reproduce the mentioned your issues in a new thread? That will help us to reproduce the issue and assist you in a better way.

Regards,
Ghous


Post Reply