EventSegmentDrag

Allows user to drag and drop event segments within the row.

Event segments
//<code-header>
fiddle.title = 'Event segments';
//</code-header>
const schedulerPro = new SchedulerPro({
    appendTo : targetElement,

    // makes scheduler as high as it needs to be to fit rows
    autoHeight : true,

    startDate : new Date(2022, 2, 20),
    endDate   : new Date(2022, 2, 27),

    columns : [
        { field : 'name', text : 'Name', width : 100 }
    ],

    project : {
        resources : [
            { id : 1, name : 'Bruce' },
            { id : 2, name : 'Diana' }
        ],

        events : [
            {
                id        : 1,
                name      : 'Art project',
                startDate : '2022-03-21',
                segments  : [
                    { startDate : '2022-03-21', duration : 1 },
                    { startDate : '2022-03-23', duration : 1 },
                    { startDate : '2022-03-25', duration : 1 }
                ]
            },
            {
                id        : 2,
                name      : 'DIY project',
                startDate : '2022-03-21',
                segments  : [
                    // segments can have their own names & colors
                    { name : 'Plan', startDate : '2022-03-21', duration : 1, eventColor : 'indigo' },
                    { name : 'Get supplies', startDate : '2022-03-23', duration : 2  }
                ]
            }
        ],

        assignments : [
            { id : 1, event : 1, resource : 1 },
            { id : 7, event : 2, resource : 2 }
        ]
    },
    features : {
        eventSegments : {
            // split at the exact date user clicks in UI
            roundedSplit : false
        }
    }
});

This feature is enabled by default

Configs

29

Properties

30

Common

disabledInstancePlugin

Class hierarchy

isEventSegmentDrag: Boolean= truereadonly
Identifies an object as an instance of EventSegmentDrag class, or subclass thereof.
isEventSegmentDrag: Boolean= truereadonlystatic
Identifies an object as an instance of EventSegmentDrag class, or subclass thereof.
isDragBaseDragBase
isEventDragEventDrag
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

alwaysCopyEventDrag
copyKeyEventDrag
copyModeEventDrag
isDraggingDragBase
modeEventDrag
showTooltipDragBase
tipDragBase
unifiedDragEventDrag

Functions

30

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

getTipHtmlDragBase
LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

22

Fired on the owning Scheduler after an event segment is dropped

// Adding a listener using the "on" method
eventSegmentDrag.on('afterEventSegmentDrop', ({ source, eventRecords, valid, context }) => {

});
ParameterTypeDescription
sourceScheduler
eventRecordsEventModel[]

Dropped segments

validBoolean
contextObject

Fired on the owning Scheduler before event segment dragging starts. Return false to prevent the action.

// Adding a listener using the "on" method
eventSegmentDrag.on('beforeEventSegmentDrag', ({ source, eventRecords, event }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Segments to drag

eventMouseEvent

Browser event

Fired on the owning Scheduler to allow implementer to use asynchronous finalization by setting context.async = true in the listener, to show a confirmation popup etc.

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

For synchronous one-time validation, simply set context.valid to true or false.

 scheduler.on('beforeEventSegmentDropFinalize', ({ context }) => {
     context.valid = false;
 })
// Adding a listener using the "on" method
eventSegmentDrag.on('beforeEventSegmentDropFinalize', ({ source, context, context.async, context.eventRecords, context.valid, context.finalize }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

contextObject
context.asyncBoolean

Set true to not finalize the drag-drop operation immediately (e.g. to wait for user confirmation)

context.eventRecordsEventModel[]

Dragged segments

context.validBoolean

Set this to false to abort the drop immediately.

context.finalizefunction

Call this method after an async finalization flow, to finalize the drag-drop operation. This method accepts one argument: pass true to update records, or false to ignore changes

Fired on the owning Scheduler when event segments are dragged

// Adding a listener using the "on" method
eventSegmentDrag.on('eventSegmentDrag', ({ source, eventRecords, startDate, endDate, context, context.valid }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

startDateDate

Start date for the current location

endDateDate

End date for the current location

contextObject
context.validBoolean

Set this to false to signal that the current drop position is invalid.

Fired on the owning Scheduler after an event segment drag operation has been aborted

// Adding a listener using the "on" method
eventSegmentDrag.on('eventSegmentDragAbort', ({ source, eventRecords }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

Fired on the owning Scheduler after an event segment drag operation regardless of the operation being cancelled or not

// Adding a listener using the "on" method
eventSegmentDrag.on('eventSegmentDragReset', ({ source }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

Fired on the owning Scheduler when event segment dragging starts

// Adding a listener using the "on" method
eventSegmentDrag.on('eventSegmentDragStart', ({ source, eventRecords, event }) => {

});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

eventMouseEvent

Browser event

Fired on the owning Scheduler when an event segment is dropped

// Adding a listener using the "on" method
eventSegmentDrag.on('eventSegmentDrop', ({ source, eventRecords }) => {

});
ParameterTypeDescription
sourceScheduler
eventRecordsEventModel[]

Dropped segments

catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin
eventDragEventDrag
eventDropEventDrag

Event handlers

22

Called on the owning Scheduler after an event segment is dropped

new EventSegmentDrag({
    onAfterEventSegmentDrop({ source, eventRecords, valid, context }) {

    }
});
ParameterTypeDescription
sourceScheduler
eventRecordsEventModel[]

Dropped segments

validBoolean
contextObject

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

new EventSegmentDrag({
    onBeforeEventSegmentDrag({ source, eventRecords, event }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Segments to drag

eventMouseEvent

Browser event

Called on the owning Scheduler to allow implementer to use asynchronous finalization by setting context.async = true in the listener, to show a confirmation popup etc.

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

For synchronous one-time validation, simply set context.valid to true or false.

 scheduler.on('beforeEventSegmentDropFinalize', ({ context }) => {
     context.valid = false;
 })
new EventSegmentDrag({
    onBeforeEventSegmentDropFinalize({ source, context }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

contextObject
context.asyncBoolean

Set true to not finalize the drag-drop operation immediately (e.g. to wait for user confirmation)

context.eventRecordsEventModel[]

Dragged segments

context.validBoolean

Set this to false to abort the drop immediately.

context.finalizefunction

Call this method after an async finalization flow, to finalize the drag-drop operation. This method accepts one argument: pass true to update records, or false to ignore changes

Called on the owning Scheduler when event segments are dragged

new EventSegmentDrag({
    onEventSegmentDrag({ source, eventRecords, startDate, endDate, context }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

startDateDate

Start date for the current location

endDateDate

End date for the current location

contextObject
context.validBoolean

Set this to false to signal that the current drop position is invalid.

Called on the owning Scheduler after an event segment drag operation has been aborted

new EventSegmentDrag({
    onEventSegmentDragAbort({ source, eventRecords }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

Called on the owning Scheduler after an event segment drag operation regardless of the operation being cancelled or not

new EventSegmentDrag({
    onEventSegmentDragReset({ source }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

Called on the owning Scheduler when event segment dragging starts

new EventSegmentDrag({
    onEventSegmentDragStart({ source, eventRecords, event }) {

    }
});
ParameterTypeDescription
sourceScheduler

Scheduler instance

eventRecordsEventModel[]

Dragged segments

eventMouseEvent

Browser event

Called on the owning Scheduler when an event segment is dropped

new EventSegmentDrag({
    onEventSegmentDrop({ source, eventRecords }) {

    }
});
ParameterTypeDescription
sourceScheduler
eventRecordsEventModel[]

Dropped segments

onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin
onEventDragEventDrag
onEventDropEventDrag

Typedefs

4