Hello, I’m trying to reproduce Gantt WorkTime Calculation in my C# backend. I save users calendar in db, an set it on my front. I Culdn`t find how calendar merge work at all, neither how Gantt really calculate work time. Someone more already reproduces Gantt Worktime calculate and calendar merge in backend side finely? And how can I do this?
Hello Rafael,
I don’t think you really need to implement the working time functionality on the backend only to merge calendars for Gantt.
If you have a set of weekend dates, you have an array. When you load that array on the client-side, you only need to specify the dates and hours for the setWorkTime
function:
https://docs.dhtmlx.com/gantt/api__gantt_setworktime.html
Here are examples:
https://snippet.dhtmlx.com/79bazp1v
https://snippet.dhtmlx.com/11kkdcqw
If you want to add or remove some dates from the array, you modify it before loading it on the client-side. If you have several calendars, you only modify the array with the dates and hours on the server-side.
And when you load the calendar data on the client-side, it will have the newer settings that will be applied by Gantt.
If you still want to implement the same functionality, here is the unminified source code file of the GPL version:
https://raw.githubusercontent.com/DHTMLX/gantt/master/codebase/sources/dhtmlxgantt.js
You can check the functions you need and manually implement similar functionality on the server-side.