Hi,
Using the demo file “02_branch_ordering.html” from dhtmlxGantt_v2.1.0_ent to demonstrate this issue.
If you drag “Task #2.1” downwards over “Task #2.2” with the intention that they should swap order, the target value returned in function onRowDragEnd is actually the Id of task “Task #2.3”.
Code to show Drag & drop details
gantt.attachEvent(“onRowDragEnd”, function(id, target) {
if (target)
{
var updatenodes = [];
var item = gantt.getTask(id);
var itemtarget = gantt.getTask(target);
console.log(item)
console.log(itemtarget)
}
});
Is their a patch to address this issue ?
Thanks
Kevin
Please try to use the attached js file instead of the original one
This is dev. version with patch applied.
dhtmlxgantt-dfix.zip (39.3 KB)
Hi,
The file attached to the previous post “dhtmlxgantt-dfix.zip” has JavaScript error “id is undefined” when creating a relationships between tasks.
Kevin
Sorry for inconvenience ( that is dev. version, it passes the main tests but still can have some problems )
Updated file is attached.
dhtmlxgantt-fix6.zip (39.3 KB)
Hi,
I am using “dhtmlx-gantt”: “^7.0.4” and I’m still facing the same problem.
It works fine when I drag task from bottom to top but it return the one position down task when I drag from top to bottom. If I drag task 1 to task 2, the target returns the task 3 id. Is there any solution?
Hello @Mohaimanul_Islam,
This behavior occurs in the scenario when the dragged task goes just after the target
task, which occurs only with replacing the last task in a chart. In this case, the target returns in the format:
next:targetId
(string).
You can read about this behavior by the following link:
https://docs.dhtmlx.com/gantt/desktop__server_side.html#storingtheorderoftasks
In this case, you can get the target id with the following code fragment:
// get id of adjacent task and check whether updated task should go before or after it
if(typeof(target) === "string"){
targetTaskId = target.substr("next:".length);
nextTask = true;
} else {
targetTaskId = target;
nextTask = false;
}
Here is a demo:
http://snippet.dhtmlx.com/5/f41b0d47d
Also, I noticed that this behavior doesn’t mention in the onRowDragEnd
topic:
https://docs.dhtmlx.com/gantt/api__gantt_onrowdragend_event.html
I sent a report to our tech writers and the documentation will be updated ASAP.
ps. Please, do not duplicate the same question in different topics, thanks.