undo for Drag and Drop tasks

Hello all,
I would like for drag and dropping of tasks to be treated as any other. I checked the output of gantt.getUndoStack() and determined that dragging and dropping tasks does not affect the undo stack. I also had a look through codebase/sources/ext/dhtmlxgantt_undo.js and wasn’t able to find any hooks into the onRowDrag events. Would there be interest in accepting patches to the undo module to get this to work, assuming I haven’t missed something?

Frank

Hello Frank,
I confirm that the extension doesn’t watch vertical drag and drop changes. We’ll add it to our tracker and probably start working on it in a couple of days. So if you have the patch already, please post it here and I forward it to the developers. Although I cannot guarantee that it will be fully or partially included into the codebase, developers might find interesting ideas how to implement it. So it will be helpful and would show a right direction. Also, if there are other people who need it, they can apply the patch manually to the current or older versions. We appreciate your efforts.

If you don’t have the patch but would like to have that functionality, here is an example how it can be implemented in the current version:
snippet.dhtmlx.com/4ba9ab937
Here we add additional column that has the current task position (index), the previous values are stored in a variable. When you click “Undo” button, each task receives previous index values for the column and gantt sorts tasks according to the previous index values.
You can create your own solution using this example. And here are the articles about the methods I used in the example:
docs.dhtmlx.com/gantt/desktop__ … lumns.html
docs.dhtmlx.com/gantt/api__gantt_sort.html
docs.dhtmlx.com/gantt/api__gant … event.html
docs.dhtmlx.com/gantt/api__gantt_eachtask.html
docs.dhtmlx.com/gantt/api__gant … event.html
docs.dhtmlx.com/gantt/api__gant … event.html

I was using the wrong terminology- what I’m actually interested in hooking is the onAfterTaskMove event. Also, I’m interested in whether the Undo stack can be modified to store a “changed” field so that I can fire API calls just for what’s changed.

Hello Frank,
Could you give an example how it can be used? The undo extension watches over the actions in the gantt chart, not over API calls.
And as I said in the previous message, Gantt doesn’t watch vertical task moves. onAfterTaskMove is an event so Undo doesn’t watch it. But if you want to hook it and execute some code, it works. In the following snippet you can see that after you move task manually or via button, you will see a popup message:
snippet.dhtmlx.com/8a0367551

I think it is not necessary to modify undo stack because it already stores the information before the task was changed and after the task was changed. You can get the values for example like this:

var custom_variable = gantt.getUndoStack()[0].commands

where 0 specifies the element in the undo events array.
You can find more information about undo functionality in this article:
docs.dhtmlx.com/gantt/desktop__ … docommands