[REACT] How to restrict the startdate and enddate to be changed based on the percentdone
Posted: Fri Jan 22, 2021 11:09 am
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
Re: [REACT] How to restrict the startdate and enddate to be changed based on the percentdone
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!