If we do it in the Timeline, and then we click autoSchedule (with specified ID), it works fine.
If we do it manually in the grid, and modify the task Start Time, and then we click autoSchedule (with specified ID), it reverts the start time back to what it was before.
Is this normal or a bug?
I would need a way to be able to automatically reschedule the Tasks when I change Start/End time manually in the grid, like it does in the Timeline.
Unfortunately, right now, the enabled property doesn’t work correctly (it is never disabled). But in the next minor update, the auto_scheduling config will always be specified as an object, so it will work correctly there.
But it doesn’t happen if the auto_scheduling config is disabled. You need to manually change the task constraint_type from asap or alap and add the constraint_date parameter after updating a task.
Here is an example of how it can be implemented:
let updateConstraint = false
gantt.ext.inlineEditors.attachEvent("onBeforeSave", function (state) {
if (state.columnName == "start_date") {
updateConstraint = state.id
}
return true
});
gantt.attachEvent("onLightboxSave", function (id, task, is_new) {
const originalTask = gantt.getTask(id);
if (+originalTask.start_date !== +task.start_date ||
+originalTask.end_date !== +task.end_date) {
updateConstraint = id;
}
return true;
})
gantt.attachEvent("onAfterTaskUpdate", function (id, task) {
if (updateConstraint && updateConstraint == id && task.constraint_type == "asap") {
task.constraint_type = "snet"
task.constraint_date = task.start_date
updateConstraint = false;
gantt.refreshTask(id)
}
});