How to send data to the server only when there is a real modification?

If I move a task and drop it in the same place, it is sent to the server. When a link exists and drags the task, the link corrects and pulls the task back to where it was. How can I prevent it from sending to the server what was not actually modified? Is the current behavior correct?

Hi @douglas!

You can compare the task’s start_date values using arguments of the callback function of the onBeforeTaskChanged event and return false if they are the same.
https://docs.dhtmlx.com/gantt/api__gantt_onbeforetaskchanged_event.html

Please check the snippet how it can be implemented:
http://snippet.dhtmlx.com/63678b689

1 Like

When I move a task, it works fine. But when I move a ‘project’ to another date, the subtasks are not updated. I saw in the console that the old date and the current date are the same in the subtask. How to solve this?

gantt.config.drag_project=true;

Hi @douglas!

If you use gantt.config.drag_project=true then please add checking task type in the condition of canceling the task’s update:

...
if (task.type == "project" && mode == "move" || mode == "resize") {
...

Here is a snippet:
http://snippet.dhtmlx.com/da2db8999

Maybe I was not clear.
When I move a ‘project’ to another date, the subtasks are not updated on the server. See the video.

Hi @douglas!

It appears to be a bug on our end using gantt.config.drag_project=true;. I’ve submitted it to our internal tracker, and the dev team will start fix it and it will be published with one of the next bugfix releases.

As a workaround for the issue you can check the type of the task in the onAfterTaskDrag event listener.
https://docs.dhtmlx.com/gantt/api__gantt_onaftertaskdrag_event.html

And if its type is project update its children tasks.

Here is a snippet you can see how it can be implemented:
http://snippet.dhtmlx.com/e1148c6b0

Note I’ve also modified date values camparing and added it in the compareDateValuesToSimilar() function.

1 Like

Hello Douglas,
I couldn’t reproduce the issue in the current version:
http://snippet.dhtmlx.com/c46577b4f
Could you clarify if the bug still affects you?