v7.3.0
SupportExamplesFree Trial

EventMenu
Feature

Displays a context menu for events. Items are populated by other features and/or application code.

targetElement.innerHTML = '<p>Right click an event bar to display a context menu:</p>'; const scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, features : { eventMenu : { items : { duplicate : { text : 'Duplicate', weight : 200, icon : 'fa fa-fw fa-copy', onItem({ item, eventRecord }) { scheduler.eventStore.add(eventRecord.copy()); } } } } }, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 13), columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Bernard' }, { id : 2, name : 'Bianca' } ], events : [ { id : 1, resourceId : 1, name : 'Interview', startDate : '2018-05-07', endDate : '2018-05-10' }, { id : 2, resourceId : 2, name : 'Meeting', startDate : '2018-05-10', endDate : '2018-05-12' }, { id : 3, resourceId : 2, name : 'Future task', startDate : '2018-06-10', endDate : '2018-06-12' } ] });

Default event menu items

Here is the list of menu items provided by the feature and populated by the other features:

Reference Text Weight Feature Description
editEvent Edit event 100 EventEdit Edit event in the event editor. Hidden when read-only
showDetails Edit event 100 EventEdit Show event in a non-editable form. Hidden when not read-only
copyEvent Copy event 110 EventCopyPaste Copy event or assignment. Hidden when read-only
cutEvent Cut event 120 EventCopyPaste Cut event or assignment. Hidden when read-only
unassignEvent Unassign event 300 This feature Unassign event. Hidden when read-only, shown for multi-assignment
deleteEvent Delete event 500 This feature Remove event. Hidden when read-only
splitEvent Split event 650 Scheduler Pro only Split an event into two segments at the mouse position
renameSegment Rename segment 660 Scheduler Pro only Show an inline editor to rename the segment
eventColor ¹ Color 400 This feature Choose background color for the event bar

¹ Set showEventColorPickers to true to enable this item

Customizing the menu items

The menu items in the Event 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 items for all events:

const scheduler = new Scheduler({
    features : {
        eventMenu : {
            items : {
                extraItem : {
                    text : 'Extra',
                    icon : 'fa fa-fw fa-flag',
                    onItem({eventRecord}) {
                        eventRecord.flagged = true;
                    }
                }
            }
        }
    }
});

Remove existing items:

const scheduler = new Scheduler({
    features : {
        eventMenu : {
            items : {
                deleteEvent   : false,
                unassignEvent : false
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    features : {
        eventMenu : {
            items : {
                deleteEvent : {
                    text : 'Delete booking'
                }
            }
        }
    }
});

Manipulate existing items for all events or specific events:

const scheduler = new Scheduler({
    features : {
        eventMenu : {
            // Process items before menu is shown
            processItems({eventRecord, items}) {
                 // Push an extra item for conferences
                 if (eventRecord.type === 'conference') {
                     items.showSessionItem = {
                         text : 'Show sessions',
                         onItem({eventRecord}) {
                             // ...
                         }
                     };
                 }

// Do not show menu for secret events if (eventRecord.type === 'secret') { return false; } } } } });

The processItems implementation may be an async function which awaits a result to mutate the items object.

Note that the menuContext is applied to the Menu's item event, so your onItem handler's single event parameter also contains the following properties:

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.

Useful configs and functions

Member Description
items Menu items configuration object
eventMenuBeforeShow Fires before menu is shown
eventMenuItem Fires when a menu item is clicked
eventMenuShow Fires after menu is shown

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • A CSS selector targeting an element, such as an ellipsis icon that when clicked will trigger the menu to show.

  • See Keyboard shortcuts for details

  • A config which will be applied when creating the Menu component.

    Has a corresponding runtime menu property.

  • Set to true to prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.

    Has a corresponding runtime preventNativeMenu property.

  • triggerEvent : 'contextmenu'/'click'/'dblclick'/null
    TimeSpanMenuBase

    Event which is used to show context menu. Available options are: 'contextmenu', 'click' and 'dblclick'. Default value is used from contextMenuTriggerEvent

  • This is a type of the context menu used to generate correct names for methods and events. Should be in camel case. Required to be set in subclass.

  • Internal listeners, that cannot be removed by the user.

  • The widget which this plugin is to attach to.

    Has a corresponding runtime client property.

  • Set to false to disable localization of this object.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEventMenu : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of EventMenu class, or subclass thereof.
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • A class property getter for the default values of internal properties for this class.

  • An informational object containing contextual information about the last activation of the context menu.

  • emptyArray : Array
    internal
    READONLY
    TimeSpanMenuBase

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    TimeSpanMenuBase

    An empty object that can be used as a default value.

  • Identifies an object as an instance of ContextMenuBase class, or subclass thereof.
  • isEventMenu : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of EventMenu class, or subclass thereof.
  • isInstancePlugin : Booleantrue
    READONLY
    ADVANCED
    TimeSpanMenuBase
    Identifies an object as an instance of InstancePlugin class, or subclass thereof.
  • Identifies an object as an instance of TimeSpanMenuBase class, or subclass thereof.
  • baseItems : Object[]
    internal
    READONLY
    TimeSpanMenuBase

    Returns the base, configured-in menu items set from the configured items, taking into account the namedItems the feature offers.

  • Gets the Menu instance that this feature is using.

    Has a corresponding menu config.

  • Set to true to prevent the native menu from showing when there are no menu items to show, or you manually prevent the menu from showing in an event listener.

    Has a corresponding preventNativeMenu config.

  • config : Object
    READONLY
    ADVANCED
    TimeSpanMenuBase

    Returns a copy of the full configuration which was used to configure this object.

  • This property is set to true before the constructor returns.

  • This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • client : Widget
    READONLY
    ADVANCED
    TimeSpanMenuBase

    The Widget which was passed into the constructor, which is the Widget we are providing extra services for.

    Has a corresponding client config.

  • Get the global LocaleHelper

  • Get the global LocaleManager

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    TimeSpanMenuBase

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    TimeSpanMenuBase

    Registers this class type with its Factory

  • Hides the context menu

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class

Type definitions

id: eventMenu

Source path

Scheduler/feature/EventMenu.js

Demo

examples/eventmenu

Contents