Wrong default date rounding on Task drag when using different Zoom level


during a task drag, there is a default mecanism that rounds the date to the closest (?) date after the onBeforeTaskDrag event.

This is ok with a zoom level where grid corresponds to days.

But if there is a higher zoom level ( weeks ), the tasks dates are correctly changed during the drag, but when the drop happens, the dates are rounded to fit the closest grid, which corresponds not to a day rounding, but to a week rounding.

I can’t find a way to disable or modify this behavior.

There is a mention of this topic on this page : https://docs.dhtmlx.com/gantt/desktop__dnd.html but I did not manage to get something working out of it.

Extract of the comment :

I have found that the example works wrong on “non-standard” zoom level.

The reason is - children dates are rounded not to the gantt.config.duration_unit/step, but to the current unit/step which results in children sticking to the current grid even if the parent task was moved by a diff less than one current unit.
I.e. if you have gantt.config.duration_unit = day, but current grid has unit/step = 1 week, if you move the parent task in the middle of the week cell, its children start dates are moved to the next or current week start date which is obviously wrong.

Proper example should be:
child.start_date = gantt.roundDate({date: child.start_date,unit: gantt.config.duration_unit,step: gantt.config.duration_step});

Can you help me with a sample of code to fix this beahavior ?

Hello Julien,
You can disable the round_dnd_dates parameter so that Gantt won’t round the dates to the nearest scale:

However, we are aware of the issue that if you drag a project with its subtasks in the year or month view, the distance between tasks will not be saved:
Unfortunately, we don’t have a fix for that.

Hello Julien,
The dev team fixed the bug with the drag_project functionality. Now, if you drag a project task in the month scale, it shouldn’t affect the duration of the project task or its subtasks. Also, the tasks should keep the distance between them:

You can check how it works in the following snippets: