Our state of the art Gantt chart


Post by Sureka »

How to restrict the startdate and enddate based on the the percentdone.
EX: if a task is in between 2 to 99 percentdone, user should not change the startdate for that
particular task but alowed to change the enddate
if a task is completed , user should not change the startdate and enddate for that task


Post by pmiklashevich »

Please extend the TaskModel and override https://www.bryntum.com/docs/gantt/#Gantt/model/TaskModel#function-isEditable to return true or false for the startDate and for the endDate fields based on the condition you want.

import ProjectModel from '../../lib/Gantt/model/ProjectModel.js';
import TaskModel from '../../lib/Gantt/model/TaskModel.js';

class MyTaskModel extends TaskModel {
    isEditable(fieldName) {
        let result = super.isEditable(fieldName);

    switch (fieldName) {
        case 'startDate' :
            result = result && this.percentDone < 2;
            break;

        case 'endDate' :
        case 'duration' :
        case 'fullDuration' :
            result = result && !this.isCompleted;
            break;
    }

    return result;
}
}

const project = new ProjectModel({
    taskModelClass : MyTaskModel,
    transport : {
        load : {
            url : '../_datasets/launch-saas.json'
        }
    }
});

You can try out this code in our Basic Gantt demo. Cheers!

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply