ScheduleMenu

Displays a context menu for empty parts of the schedule. Items are populated in the first place by configurations of this Feature, then by other features and/or application code.

Default scheduler zone menu items

The Scheduler menu feature provides only one item:

Reference Text Weight Feature Description
addEvent Add event 100 This feature Add new event at the target time and resource. Hidden when read-only
pasteEvent Paste event 110 EventCopyPaste Paste event at the target time and resource. Hidden when is read-only
splitSchedule Split 200 Split Shows the "Split schedule" sub-menu
> splitHorizontally Horizontally 100 Split Split horizontally
> splitVertically Vertically 200 Split Split vertically
> splitBoth Both 300 Split Split both ways
unsplitSchedule Split 210 Split Unsplit a previously split schedule
>
first level of submenu

Customizing the menu items

The menu items in the Scheduler menu can be customized, existing items can be changed or removed, and new items can be added. This is handled using the items config of the feature.

Add extra item:

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            items : {
                extraItem : {
                    text : 'Extra',
                    icon : 'fa fa-fw fa-flag',
                    onItem({date, resourceRecord, items}) {
                        // Custom date based action
                    }
                }
            }
        }
    }
});

Remove existing item:

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            items : {
                addEvent : false
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            items : {
                addEvent : {
                    text : 'Create new booking'
                }
            }
        }
    }
});

Manipulate existing items:

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            // Process items before menu is shown
            processItems({date, resourceRecord, items}) {
                 // Add an extra item for ancient times
                 if (date < new Date(2018, 11, 17)) {
                     items.modernize = {
                         text : 'Modernize',
                         ontItem({ date }) {
                             // Custom date based action
                         }
                     };
                 }

                 // Do not show menu for Sundays
                 if (date.getDay() === 0) {
                     return false;
                 }
            }
        }
    }
});
The `processItems` implementation my be an `async` function which `awaits` a result to mutate the `items` object.

Video guides

Full information of the menu customization can be found in the "Customizing the Event menu, the Schedule menu, and the TimeAxisHeader menu" guide.

This feature is enabled by default

Configs

18

Common

disabledInstancePlugin
listenersEvents

Other

items: Object<String, MenuItemEntry>

This is a preconfigured set of items used to create the default context menu.

The items provided by this feature are listed below. These are the predefined property names which you may configure:

  • addEvent Add an event for at the resource and time indicated by the contextmenu event.

To remove existing items, set corresponding keys null:

const scheduler = new Scheduler({
    features : {
        scheduleMenu : {
            items : {
                addEvent : null
            }
        }
    }
});
processItems: function

A function called before displaying the menu that allows manipulations of its items. Returning false from this function prevents the menu being shown.

features         : {
   scheduleMenu : {
        processItems({ items, date, resourceRecord }) {
           // Add or hide existing items here as needed
           items.myAction = {
               text   : 'Cool action',
               icon   : 'fa fa-cat',
               onItem : () => console.log(`Clicked on ${resourceRecord.name} at ${date}`),
               weight : 1000 // Move to end
           };

           if (!resourceRecord.allowAdd) {
               items.addEvent.hidden = true;
           }
       }
   }
},
ParameterTypeDescription
contextObject

An object with information about the menu being shown

context.featureScheduleMenu

A reference to this feature.

context.domEventEvent

The initiating event.

context.eventEvent

DEPRECATED: The initiating event.

context.pointNumber[]

The client X and Y position of the initiating event.

context.targetElementHTMLElement

The target to which the menu is being applied.

context.resourceRecordResourceModel

The record representing the current resource

context.dateDate

The clicked date

context.itemsObject<String, MenuItemEntry>

An object containing the menu item configs keyed by their id.

Returns: Boolean | null -

Returning false from this function prevents the menu being shown

clickTriggerSelectorContextMenuBase
keyMapContextMenuBase
menuContextMenuBase
namedItemsContextMenuBase
preventNativeMenuContextMenuBase
triggerEventContextMenuBase
typeContextMenuBase

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

20

Common

disabledInstancePlugin

Class hierarchy

isScheduleMenu: Boolean= truereadonly
Identifies an object as an instance of ScheduleMenu class, or subclass thereof.
isScheduleMenu: Boolean= truereadonlystatic
Identifies an object as an instance of ScheduleMenu class, or subclass thereof.
isContextMenuBaseContextMenuBase
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable
isTimeSpanMenuBaseTimeSpanMenuBase

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

menuContextMenuBase
menuContextContextMenuBase
preventNativeMenuContextMenuBase

Functions

29

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
showContextMenuContextMenuBase
triggerEvents
unEvents

Events

10

This event fires on the owning Scheduler or Gantt widget before the context menu is shown for the schedule. Allows manipulation of the items to show in the same way as in processItems. Returning false from a listener prevents the menu from being shown.

// Adding a listener using the "on" method
scheduleMenu.on('scheduleMenuBeforeShow', ({ source, items, resourceRecord, date, assignmentRecord, eventElement }) => {

});
ParameterTypeDescription
sourceScheduler
itemsObject<String, MenuItemEntry>

Menu item configs

resourceRecordResourceModel

Resource record

dateDate

Clicked date, rounded according to viewPreset's settings

assignmentRecordAssignmentModel

Assignment record, if assignments are used

eventElementHTMLElement

This event fires on the owning Scheduler or Gantt widget when an item is selected in the context menu.

// Adding a listener using the "on" method
scheduleMenu.on('scheduleMenuItem', ({ source, item, resourceRecord, date, element }) => {

});
ParameterTypeDescription
sourceScheduler
itemMenuItem
resourceRecordResourceModel
dateDate

Clicked date, rounded according to viewPreset's settings

elementHTMLElement

This event fires on the owning Scheduler or Gantt widget after showing the context menu for the schedule.

// Adding a listener using the "on" method
scheduleMenu.on('scheduleMenuShow', ({ source, items, menu, resourceRecord, date, targetElement }) => {

});
ParameterTypeDescription
sourceScheduler
itemsObject<String, MenuItemEntry>

Menu item configs

menuMenu

The menu

resourceRecordResourceModel
dateDate

Clicked date, rounded according to viewPreset's settings

targetElementHTMLElement
catchAllEvents
contextMenuItemContextMenuBase
contextMenuToggleItemContextMenuBase
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

10

This event called on the owning Scheduler or Gantt widget before the context menu is shown for the schedule. Allows manipulation of the items to show in the same way as in processItems. Returning false from a listener prevents the menu from being shown.

new ScheduleMenu({
    onScheduleMenuBeforeShow({ source, items, resourceRecord, date, assignmentRecord, eventElement }) {

    }
});
ParameterTypeDescription
sourceScheduler
itemsObject<String, MenuItemEntry>

Menu item configs

resourceRecordResourceModel

Resource record

dateDate

Clicked date, rounded according to viewPreset's settings

assignmentRecordAssignmentModel

Assignment record, if assignments are used

eventElementHTMLElement

This event called on the owning Scheduler or Gantt widget when an item is selected in the context menu.

new ScheduleMenu({
    onScheduleMenuItem({ source, item, resourceRecord, date, element }) {

    }
});
ParameterTypeDescription
sourceScheduler
itemMenuItem
resourceRecordResourceModel
dateDate

Clicked date, rounded according to viewPreset's settings

elementHTMLElement

This event called on the owning Scheduler or Gantt widget after showing the context menu for the schedule.

new ScheduleMenu({
    onScheduleMenuShow({ source, items, menu, resourceRecord, date, targetElement }) {

    }
});
ParameterTypeDescription
sourceScheduler
itemsObject<String, MenuItemEntry>

Menu item configs

menuMenu

The menu

resourceRecordResourceModel
dateDate

Clicked date, rounded according to viewPreset's settings

targetElementHTMLElement
onContextMenuItemContextMenuBase
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

3
MenuContextContextMenuBase
MenuItemEntryContextMenuBase