v7.3.0
SupportExamplesFree Trial

ResourceMenu
Feature

Applicable only for Scheduler in vertical mode. Right click resource header cells to display a context menu.

To invoke the menu in a keyboard-accessible manner, use the Space key when a resource cell is focused.

targetElement.innerHTML = '<p>Right click a resource header cell to display the context menu</p>'; const scheduler = new Scheduler({ appendTo : targetElement, mode : 'vertical', // makes scheduler as high as it needs to be to fit rows height : 600, resourceImagePath : 'data/Scheduler/images/transparent-users/', features : { resourceMenu : { items : { // We add an extra item to the resource menu add : { text : 'Add resource', icon : 'fa fa-plus', onItem : ({ resourceRecord }) => scheduler.resourceStore.insert(scheduler.resourceStore.indexOf(resourceRecord), { name : 'John Doe' }) } } } }, startDate : new Date(2023, 4, 8, 8), endDate : new Date(2023, 4, 8, 20), viewPreset : 'hourAndDay', columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Arnold Smith', image : 'arnold.png', eventColor : 'yellow' }, { id : 2, name : 'Gloria Rogers', image : 'gloria.png', eventColor : 'blue' }, { id : 3, name : 'Emilia Miller', eventColor : 'indigo', image : 'emilia.jpg' } ], events : [ { id : 1, resourceId : 1, name : 'Interview', startDate : '2023-05-08T09:00:00', endDate : '2023-05-08T11:00:00' }, { id : 2, resourceId : 2, name : 'Meeting', startDate : '2023-05-08T15:00:00', endDate : '2023-05-08T19:00:00' }, { id : 3, resourceId : 3, name : 'Conference', startDate : '2023-05-08T09:00:00', endDate : '2023-05-08T17:00:00' } ] });

Default menu items

The ResourceMenu feature provides only one item by default:

Reference Text Weight Description
remove Delete 100 Delete the resource

Customizing the menu items

The menu items in the resource 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 columns:

const scheduler = new Scheduler({
    mode     : 'vertical',
    features : {
        resourceMenu : {
            items : {
                extraItem : {
                    text   : 'My cell item',
                    icon   : 'fa fa-bus',
                    weight : 200,
                    onItem : () => ...
                }
            }
        }
    }
});

Remove an existing item:

const scheduler = new Scheduler({
    mode     : 'vertical',
    features : {
        resourceMenu : {
            items : {
                remove : null
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    mode     : 'vertical',
    features : {
        resourceMenu : {
            items : {
                remove : {
                    text : 'Remove',
                    icon : 'fa fa-dumpster'
                }
            }
        }
    }
});

It is also possible to manipulate the default items and add new items in the processing function:

const scheduler = new Scheduler({
    mode     : 'vertical',
    features : {
        resourceMenu : {
            processItems({items, record}) {
                if (record.cost > 5000) {
                    items.myItem = { text : 'Split cost' };
                }
            }
        }
    }
});

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

This feature is disabled by default.

Useful configs and functions

Member Description
resourceMenuBeforeShow Fires before menu is shown
resourceMenuItem Fires when a menu item is clicked
resourceMenuShow 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
    ContextMenuBase

    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
  • 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.
  • isResourceMenu : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of ResourceMenu class, or subclass thereof.
  • A class property getter for the default values of internal properties for this class.

  • emptyArray : Array
    internal
    READONLY
    ContextMenuBase

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

  • emptyObject : Object
    internal
    READONLY
    ContextMenuBase

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

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

    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.

  • An informational object containing contextual information about the last activation of the context menu. The base properties are listed below. Some subclasses may add extra contextual information such as eventRecord and resourceRecord to the block.

  • 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
    ContextMenuBase

    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
    ContextMenuBase

    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
    ContextMenuBase

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

  • initClass( )
    static
    ADVANCED
    ContextMenuBase

    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
id: resourceMenu

Source path

Scheduler/feature/ResourceMenu.js

Demo

examples/vertical

Contents