Our state of the art Gantt chart


Post by beotech »

By default it is not possible to edit the end date on parent tasks, but only on final tasks, whereas it is possible to edit the start date of any task.

End date.PNG
End date.PNG (58.49 KiB) Viewed 672 times

We would like to be able to edit the end date of any task too but we could not find a way so far.

The 'beforeCellEditStart' and 'startCellEdit' events are not even triggered when clicking on a parent task end date column.

Is there any config somewhere we can modify (EndDateColumn, EndDateField, Gantt feature, ...) ?
If not, could you provide some code to help us achieve this ?


Post by saki »

See please this answer and especially the scheduling guide – manually scheduled tasks are described at the beginning of the guide.


Post by arcady »

Parent tasks roll up start/end dates of their children. That's why they are not editable (except if they are manually scheduled ..then they are editable since in this case user should provide start/end dates).

There is a method that enables/disables a task field ability to be edited: https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#function-isEditable

You can try overriding to implement a custom behaviour.


Post by beotech »

We are well aware of all these rules concerning the scheduling engine and roll up for parent tasks, but we need to be able to modify parent tasks end date.

A the moment IT IS POSSIBLE to modify the parent task START date, which will modify the children if the changed date is compatible with all the constraints.

How can we achieve same behaviour for the end date ?


Post by arcady »

Well that's doable but requires some TaskModel methods hacking.

First of all as I said you need to mark the field as editable by overriding https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#function-isEditable method:

export default class Task extends TaskModel {

    // Override to make task endDate field editable
    isEditable(fieldName) {
        return fieldName === 'endDate' || super.isEditable(...arguments);
    }

Next you need to override setEndDate method . The method has 2nd parameter keepDuration which is false by default which means that endDate changing means task "resize" instead of task "move".
And as far as I understand you want to move the task in this case:

    setEndDate(date, keepDuration) {
        // set keepDuration to true by default
        if (keepDuration === undefined) keepDuration = true;
        return super.setEndDate(date, keepDuration);
    }

And the last required override is isConstraintTypeApplicable method one.

We need to allow Finish No Earlier Than (FNET) constraints for parent tasks. So changing of such tasks end date will cause setting of such constraint:

    * isConstraintTypeApplicable(constraintType) {
        // enable FNET constraint all tasks (including summaries)
        return (constraintType === 'finishnoearlierthan') || (yield * super.isConstraintTypeApplicable(constraintType));
    }

So the whole override will look something like this:

export default class Task extends TaskModel {

    // Override to make task endDate field editable
    isEditable(fieldName) {
        return fieldName === 'endDate' || super.isEditable(...arguments);
    }

    setEndDate(date, keepDuration) {
        // set keepDuration to true by default
        if (keepDuration === undefined) keepDuration = true;
        return super.setEndDate(date, keepDuration);
    }

    * isConstraintTypeApplicable(constraintType) {
        // enable FNET constraint all tasks (including summaries)
        return (constraintType === 'finishnoearlierthan') || (yield * super.isConstraintTypeApplicable(constraintType));
    }

}

Post by beotech »

Thank you for your answer but the method "isEditable" does not exist in the Bryntum version we use at the moment (4.0.0) and we cannot upgrade for now.

Thus we will try to figure out another way.


Post Reply