In my project, after the drag is over, the time becomes 16:00, but my working hours are 09:00-17:00.
Look at this GIF
The start time and end time should be 09:00 and 17:00.
The start time should be 2024-08-29 09:00:00 The end time should be 2024-08-30 17:00:00.
Is there any configuration?
Is there any configuration that allows the start time of the working time to be 09:00 and the end time to be 17:00 after the end of the drag and drop?
Hello Menglin,
After you finish dragging the task, Gantt snaps the task to the nearest cell which is 16:00.
The setWorkTime method only specifies the working hours. It means that the duration outside the working hours is not included. It doesn’t correct the task position on drag.
So, if the task duration is 8 hours and the task starts at 16:00, it is 1 working hour for the current day and 7 working hours for the following day. So, the task ends 16:00 the next day. There is nothing wrong with that in Gantt.
I see that in the snippet, the tasks appear to start from 09:04, and it looks as if it is a bug in Gantt. But the cause of the issue is the wrong Gantt configuration.
First, the date format is not correct. You set the format to %Y-%d-%m %H:%m:%s, but the task dates have this format: %m-%d-%Y. So, if you disable auto-scheduling, the dates will be in 190X year - and that reveals the wrong date format.
Second, the %m means month only. But you are trying to use it both as the month and as minutes:
There is no built-in way to snap the dates only to the start and end of the working time. You need to implement a custom solution by using the Gantt API and Javascript.