onBeforeRowDragEnd
Description
Fires when a user drops a row in the grid
onBeforeRowDragEnd: (sid: string | number, parent: string | number, tindex: number) => boolean;
Parameters
sid- (required) string | number - the id of the task to moveparent- (required) string | number - the parent id. Check the details belowtindex- (required) number - the index of the position that the task will be moved from
(the index in the whole tree). If specified, the tindex will refer to the index in the 'parent' branch. Check the details below
Returns
result- (boolean) - defines whether the default action of the event will be triggered (true) or canceled (false)
Example
gantt.attachEvent("onBeforeRowDragEnd", function(id, parent, tindex){
const task = gantt.getTask(id);
if(task.parent != parent)
return false;
return true;
});
Related samples
Details
note
The event is fired when a task is moved by the mouse pointer in the left-hand grid, while the order_branch setting is enabled. If branch reordering is disabled, the event will never be called.
- When the event is fired the task is already moved to a new position, but the changes still can be reverted
- The event is blockable. Return false operation and move task to it's original location
- Original position (parent and index) are available from handler arguments
- Target position can be retrieved from a task object as task.parent and gantt.getGlobalTaskIndex(taskId)
- The parent and tindex parameters depend on the set order_branch mode:
- In the regular mode ("true"):
- the parent parameter refers to the original task's parent (the parent of a task before it was moved to a new position)
- the tindex parameter refers to the original local index
- In the "marker" mode:
- the parent parameter refers to the new task's parent
- the tindex parameter refers to the new local index
- In the regular mode ("true"):