TaskSegmentDrag

Allows user to drag and drop task segments, to change their start date.

Task segments
//<code-header>
fiddle.title = 'Task segments';
//</code-header>
const gantt = new Gantt({
    appendTo  : targetElement,
    height    : 200,
    startDate : '2022-07-25',
    endDate   : '2022-08-01',
    rowHeight : 60,
    project   : new ProjectModel({
        startDate : '2022-07-25',
        events    : [
            {
                id        : 1,
                name      : 'Task A',
                startDate : '2022-07-25',
                duration  : 3,
                segments  : [
                    {
                        startDate : '2022-07-25',
                        duration  : 2
                    },
                    {
                        startDate : '2022-07-28',
                        duration  : 1
                    }
                ]
            },
            {
                id        : 2,
                name      : 'Task B',
                startDate : '2022-07-25',
                duration  : 3,
                segments  : [
                    {
                        startDate : '2022-07-25',
                        duration  : 1
                    },
                    {
                        startDate : '2022-07-27',
                        duration  : 2
                    },
                    {
                        startDate : '2022-07-30',
                        duration  : 1
                    }
                ]
            }
        ]
    })
});

This feature is enabled by default

Configs

21

Properties

23

Common

disabledInstancePlugin

Class hierarchy

isTaskSegmentDrag: Boolean= truereadonly
Identifies an object as an instance of TaskSegmentDrag class, or subclass thereof.
isTaskSegmentDrag: Boolean= truereadonlystatic
Identifies an object as an instance of TaskSegmentDrag class, or subclass thereof.
isDragBaseDragBase
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable
isTaskDragTaskDrag

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

isDraggingDragBase
showTooltipDragBase
tipDragBase

Functions

29

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

getTipHtmlDragBase
LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

17

Fires on the owning Gantt after a task drop, regardless if the drop validity

// Adding a listener using the "on" method
taskSegmentDrag.on('afterTaskSegmentDrop', ({ source, taskRecords, valid }) => {

});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dropped segments

validBoolean

Fires on the owning Gantt before segment dragging starts. Return false to prevent the action.

// Adding a listener using the "on" method
taskSegmentDrag.on('beforeTaskSegmentDrag', ({ source, taskRecord, event }) => {

});
ParameterTypeDescription
sourceGantt
taskRecordTaskModel

The segment about to be dragged

eventEvent

The native browser event

Fires on the owning Gantt to allow implementer to prevent immediate finalization by setting data.context.async = true in the listener, to show a confirmation popup etc

scheduler.on('beforetasksegmentdropfinalize', ({ context }) => {
    context.async = true;
    setTimeout(() => {
        // async code don't forget to call finalize
        context.finalize();
    }, 1000);
})
// Adding a listener using the "on" method
taskSegmentDrag.on('beforeTaskSegmentDropFinalize', ({ source, context, context.taskRecords, context.valid, context.async, context.finalize }) => {

});
ParameterTypeDescription
sourceGantt

Gantt instance

contextObject
context.taskRecordsTaskModel[]

Dragged segments

context.validBoolean

Set this to false to mark the drop as invalid

context.asyncBoolean

Set true to handle dragdrop asynchronously (e.g. to wait for user confirmation)

context.finalizefunction

Call this method to finalize dragdrop. This method accepts one argument: pass true to update records, or false, to ignore changes

Fires on the owning Gantt while a segment is being dragged

// Adding a listener using the "on" method
taskSegmentDrag.on('taskSegmentDrag', ({ source, taskRecords, startDate, endDate, dragData, changed }) => {

});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dragged segments

startDateDate
endDateDate
dragDataObject
changedBoolean

true if startDate has changed.

Fires on the owning Gantt when segment dragging starts

// Adding a listener using the "on" method
taskSegmentDrag.on('taskSegmentDragStart', ({ source, taskRecords }) => {

});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dragged segments

Fires on the owning Gantt after a valid task drop

// Adding a listener using the "on" method
taskSegmentDrag.on('taskSegmentDrop', ({ source, taskRecords, isCopy }) => {

});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dropped segments

isCopyBoolean
catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin
taskDragTaskDrag
taskDropTaskDrag

Event handlers

17

Called on the owning Gantt after a task drop, regardless if the drop validity

new TaskSegmentDrag({
    onAfterTaskSegmentDrop({ source, taskRecords, valid }) {

    }
});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dropped segments

validBoolean

Called on the owning Gantt before segment dragging starts. Return false to prevent the action.

new TaskSegmentDrag({
    onBeforeTaskSegmentDrag({ source, taskRecord, event }) {

    }
});
ParameterTypeDescription
sourceGantt
taskRecordTaskModel

The segment about to be dragged

eventEvent

The native browser event

Called on the owning Gantt to allow implementer to prevent immediate finalization by setting data.context.async = true in the listener, to show a confirmation popup etc

scheduler.on('beforetasksegmentdropfinalize', ({ context }) => {
    context.async = true;
    setTimeout(() => {
        // async code don't forget to call finalize
        context.finalize();
    }, 1000);
})
new TaskSegmentDrag({
    onBeforeTaskSegmentDropFinalize({ source, context }) {

    }
});
ParameterTypeDescription
sourceGantt

Gantt instance

contextObject
context.taskRecordsTaskModel[]

Dragged segments

context.validBoolean

Set this to false to mark the drop as invalid

context.asyncBoolean

Set true to handle dragdrop asynchronously (e.g. to wait for user confirmation)

context.finalizefunction

Call this method to finalize dragdrop. This method accepts one argument: pass true to update records, or false, to ignore changes

Called on the owning Gantt while a segment is being dragged

new TaskSegmentDrag({
    onTaskSegmentDrag({ source, taskRecords, startDate, endDate, dragData, changed }) {

    }
});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dragged segments

startDateDate
endDateDate
dragDataObject
changedBoolean

true if startDate has changed.

Called on the owning Gantt when segment dragging starts

new TaskSegmentDrag({
    onTaskSegmentDragStart({ source, taskRecords }) {

    }
});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dragged segments

Called on the owning Gantt after a valid task drop

new TaskSegmentDrag({
    onTaskSegmentDrop({ source, taskRecords, isCopy }) {

    }
});
ParameterTypeDescription
sourceGantt
taskRecordsTaskModel[]

Dropped segments

isCopyBoolean
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin
onTaskDragTaskDrag
onTaskDropTaskDrag

Typedefs

2