Hello,
Reset the Gantt chart in 2 seconds.
Why is event onAfterTaskUpdate not triggered?
Hello,
Reset the Gantt chart in 2 seconds.
Why is event onAfterTaskUpdate not triggered?
Hello,
Here are the steps of what happens in your case:
1) In your function, you try to add a calendar with the wrong configuration. There is no date
property in the worktime
object for the addCalendar
method:
https://docs.dhtmlx.com/gantt/api__gantt_addcalendar.html#:~:text=The%20calendar%20configuration%20object%20can%20contain%20the%20following%20attributes%3A
So, Gantt obtains only the hours
parameter. It has the true
value, but Gantt needs something more specific. The value can be false
, then all hours will be non-working (though it is not a valid calendar when all week days are non-working). Otherwise, Gantt needs an array with the working hours.
As a result, the calendar is not added.
2) As the calendar is not added, the calendarId
becomes null
. So, Gantt uses the global calendar for the task #1.
3) You make Tuesdays as weekend days, and it is applied for all tasks.
4) Then you parse the data. As the tasks already exist, they are replaced by what you have in the provided ganttData
object.
The onAfterTaskUpdate
event is not supposed to fire when you load tasks. It doesn’t happen during the initial load and the following loads. It can fire only if a task is auto-scheduled after it is loaded or if there is a custom code that calls the updateTask
method.
Here is an example where initially, the task starts on a weekend, but is moved to the working day because of the correct_work_time
config:
https://snippet.dhtmlx.com/u4xm77a8
The onAfterTaskUpdate
event doesn’t fire here as well, but it is expected behavior.
5) After that, you call the autoSchedule
method, but there is no need to auto-schedule tasks to different dates, so no task is updated.
If you expect the event to fire for the tasks #2.2 and 2.4 it doesn’t happen, because Gantt modified the dataset you used in the parse
method.
If you check the variable after loading the data, you can see that it has the updated dates for all tasks:
https://snippet.dhtmlx.com/ydf42t5p
If you don’t want Gantt to modify the variable, you need to enable the deepcopy_on_parse
config:
https://docs.dhtmlx.com/gantt/api__gantt_deepcopy_on_parse_config.html
Here is the updated snippet:
https://snippet.dhtmlx.com/j9t1jzro
Hello,
My version is 7.1.13 PRO.
Found that updates are not triggered on this version
Same code
Hello,
I added the 7.1.13 version to the snippet instead of the 8.0 version, but I don’t see the difference:
https://files.dhtmlx.com/30d/5429e9a630eb140824a272a775d0b733/vokoscreen-2024-09-24_13-28-09.mp4