enables advanced drag-n-drop
gantt.config.click_drag = {
callback: function(
startPosition,
endPosition,
startDate,
endDate,
tasksBetween,
rowsBetween
){
var parentId = gantt.config.root_id;
if(rowsBetween.length){
parentId = rowsBetween[0].id;
}
gantt.createTask({
text: "New task",
start_date: gantt.roundDate(startDate),
end_date: gantt.roundDate(endDate)
}, parentId);
},
singleRow: true
};
This config is defined in the click_drag extension, so you need to activate the click_drag plugin using the gantt.plugins method. Read the details in the Creating/Selecting Tasks with DnD article.
The click_drag extension allows:
The gantt.config.click_drag object includes the following properties:
{absolute: {left: number, top: number}, relative: {left: number, top: number} }
, {absolute: {left: number, top: number}, relative: {left: number, top: number} }
, gantt.config.click_drag = {
callback: onDragEnd,
ignore: ".gantt_task_line, .gantt_marker_content, .gantt_task_link",
useKey: "ctrlKey"
};
{absolute: {left: number, top: number}, relative: {left: number, top: number} }
, {absolute: {left: number, top: number}, relative: {left: number, top: number} }
, Here is an example of usage of the render function:
var node;
gantt.config.click_drag = {
callback: onDragEnd,
singleRow: true,
render: function(start, end){
if(!(node && node.parentNode)){
node = document.createElement("div");
}
var left = Math.min(start.relative.left, end.relative.left);
node.style.top = (start.relative.top - gantt.config.row_height) + "px";
node.style.left = left + "px";
node.style.width = Math.abs(start.relative.left - end.relative.left) + "px";
node.style.height = gantt.config.row_height + "px";
node.style.position = "absolute";
return node;
}
};