Hi,
I created dragdrop functionally in Gantt. (I drop on the gantt itself, not using + in sidebar) All is well. Task is created on the right spot. But after reloading the task drops to the bottom. This seems logical because in php the store methode creates the sort order by adding 1 to the last sort order.
How can I append/send the task.index with the createTask methode in JS so I can calculate the order just as is done with the updateTask api call, as the index is not provided on the call to the backend.
With the updateTask “target” is provided in the request. But not so on createTask.
Regards,
Robin
function onDragEnd(startPoint,endPoint,startDate,endDate,tasksBetweenDates,tasksInRow){
if (tasksInRow.length === 1) {
var parent = tasksInRow[0];
// var index = tasksInRow[0].$index+1;
var index = gantt.getTaskIndex(parent.id);
console.log(parent);
gantt.createTask({
text:"New task",
start_date: gantt.roundDate(startDate),
end_date: gantt.roundDate(endDate),
}, parent.parent, index);
} else if (tasksInRow.length === 0) {
gantt.createTask({
text:"New task",
start_date: gantt.roundDate(startDate),
end_date: gantt.roundDate(endDate),
} );
}
}