Round drag and drop to days

Hi there,

I have round_dnd_dates turned on if my zoom level isset to “day”, otherwise it will be false

When I move a task in “month” zoom level, there is a big chance it will be dropped in the middle of day

image

Is there any way to round dropped task to start of day?

Hello,
When you disable the round_dnd_dates parameter, Gantt won’t round the task to the nearest scale border. The task will have the same position where you placed it. So, it is expected behavior that the tasks don’t always start at the beginning of the day.
You need to manually round their dates with the gantt.date.day_start method in the onAfterTaskDrag event handler:
https://docs.dhtmlx.com/gantt/api__gantt_date_other.html
https://docs.dhtmlx.com/gantt/api__gantt_onaftertaskdrag_event.html

Here is an example of how it might be implemented:
http://snippet.dhtmlx.com/5/b90cb3af8

1 Like

Thank you @ramil

I have tried so many things in onAfterTaskDrag event handler, but not that gantt.date.day_start :sweat_smile: