TimeAxisHeaderMenu

Adds scheduler specific menu items to the timeline header context menu.

Time axis header menu
//<code-header>
fiddle.title = 'Time axis header menu';
//</code-header>
targetElement.innerHTML = '<p>Right click the timeline header to display its context menu:</p>';
const scheduler = new Scheduler({
    appendTo : targetElement,

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

    features : {
        timeAxisHeaderMenu : {
            extraItems : [
                {
                    text   : 'Zoom to fit',
                    weight : 200,
                    icon   : 'fa fa-fw fa-arrows-alt',
                    cls    : 'b-separator',
                    onItem({ item }) {
                        scheduler.zoomToFit();
                    }
                },
                {
                    text   : 'Custom item',
                    weight : 201,
                    icon   : 'fa fa-fw fa-cog',
                    onItem({ item }) {
                        Toast.show('You clicked a Custom item');
                    }
                }
            ]
        }
    },

    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 time axis header menu items

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

Reference Text Weight Feature Description
eventsFilter Filter tasks 100 EventFilter Submenu for event filtering
>nameFilter By name 110 EventFilter Filter by name
Removed when a mode of a Calendar
zoomLevel Zoom 200 This feature Submenu for timeline zooming
>zoomSlider - 210 This feature Changes current zoom level
dateRange Date range 300 This feature Submenu for timeline range
setRange Time range 300 Only added when a mode of a Calendar Sets the Scheduler'srange
Replaces the Date range menu item
>startDateField Start date 310 This feature Start date for the timeline
>endDateField End date 320 This feature End date for the timeline
>leftShiftBtn < 330 This feature Shift backward
>todayBtn Today 340 This feature Go to today
>rightShiftBtn > 350 This feature Shift forward
currentTimeLine Show current timeline 400 TimeRanges Show current time line
>
first level of submenu

Customizing the menu items

The menu items in the TimeAxis Header 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:

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

Remove existing items:

const scheduler = new Scheduler({
    features : {
        timeAxisHeaderMenu : {
            items : {
                zoomLevel : false
            }
        }
    }
});

Customize existing item:

const scheduler = new Scheduler({
    features : {
        timeAxisHeaderMenu : {
            items : {
                zoomLevel : {
                    text : 'Scale'
                }
            }
        }
    }
});

Customizing submenu items:

const scheduler = new Scheduler({
     features : {
         timeAxisHeaderMenu : {
             items : {
                 dateRange : {
                     menu : {
                         items : {
                             todayBtn : {
                                 text : 'Now'
                             }
                         }
                     }
                 }
             }
         }
     }
});

Manipulate existing items:

const scheduler = new Scheduler({
    features : {
        timeAxisHeaderMenu : {
            // Process items before menu is shown
            processItems({ items }) {
                 // Add an extra item dynamically
                items.coolItem = {
                    text : 'Cool action',
                    onItem() {
                          // ...
                    }
                }
            }
        }
    }
});
The `processItems` implementation my be an `async` function which `awaits` a result to mutate the `items` object.

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

Video guides

This feature is enabled by default

Configs

19

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 in the intro section of this class. You can configure existing items by passing a configuration object to the keyed items.

To remove existing items, set corresponding keys null:

const scheduler = new Scheduler({
    features : {
        timeAxisHeaderMenu : {
            items : {
                eventsFilter : null
            }
        }
    }
});

See the feature config in the above example for details.

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         : {
      timeAxisHeaderMenu : {
          processItems({ items }) {
              // Add or hide existing items here as needed
              items.myAction = {
                  text   : 'Cool action',
                  icon   : 'fa fa-fw fa-ban',
                  onItem : () => console.log('Some coolness'),
                  weight : 300 // Move to end
              };

              // Hide zoom slider
              items.zoomLevel.hidden = true;
          }
      }
  },
ParameterTypeDescription
contextObject

An object with information about the menu being shown.

context.featureTimeAxisHeaderMenu

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.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
keyMapHeaderMenu
menuContextMenuBase
namedItemsContextMenuBase
preventNativeMenuContextMenuBase
triggerEventContextMenuBase
typeContextMenuBase

Accessibility

moveColumnsHeaderMenu

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

20

Common

disabledInstancePlugin

Class hierarchy

isTimeAxisHeaderMenu: Boolean= truereadonly
Identifies an object as an instance of TimeAxisHeaderMenu class, or subclass thereof.
isTimeAxisHeaderMenu: Boolean= truereadonlystatic
Identifies an object as an instance of TimeAxisHeaderMenu class, or subclass thereof.
isContextMenuBaseContextMenuBase
isEventsEvents
isHeaderMenuHeaderMenu
isInstancePluginInstancePlugin
isLocalizableLocalizable

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

14

This event fires on the owning Scheduler or Gantt widget before the context menu is shown for the time axis header. Allows manipulation of the items to show in the same way as in the processItems.

Returning false from a listener prevents the menu from being shown.

// Adding a listener using the "on" method
timeAxisHeaderMenu.on('timeAxisHeaderMenuBeforeShow', ({ source, menu, items, column }) => {

});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemsObject<String, MenuItemEntry>

Menu item configs

columnColumn

Time axis column

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

// Adding a listener using the "on" method
timeAxisHeaderMenu.on('timeAxisHeaderMenuItem', ({ source, menu, item, column }) => {

});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemMenuItem

Selected menu item

columnColumn

Time axis column

This event fires on the owning Scheduler or Gantt widget after the context menu is shown for a header

// Adding a listener using the "on" method
timeAxisHeaderMenu.on('timeAxisHeaderMenuShow', ({ source, menu, items, column }) => {

});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemsObject<String, MenuItemEntry>

Menu item configs

columnColumn

Time axis column

catchAllEvents
contextMenuItemContextMenuBase
contextMenuToggleItemContextMenuBase
destroyEvents
disableInstancePlugin
enableInstancePlugin
headerMenuItemHeaderMenu
headerMenuShowHeaderMenu

Event handlers

14

This event called on the owning Scheduler or Gantt widget before the context menu is shown for the time axis header. Allows manipulation of the items to show in the same way as in the processItems.

Returning false from a listener prevents the menu from being shown.

new TimeAxisHeaderMenu({
    onTimeAxisHeaderMenuBeforeShow({ source, menu, items, column }) {

    }
});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemsObject<String, MenuItemEntry>

Menu item configs

columnColumn

Time axis column

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

new TimeAxisHeaderMenu({
    onTimeAxisHeaderMenuItem({ source, menu, item, column }) {

    }
});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemMenuItem

Selected menu item

columnColumn

Time axis column

This event called on the owning Scheduler or Gantt widget after the context menu is shown for a header

new TimeAxisHeaderMenu({
    onTimeAxisHeaderMenuShow({ source, menu, items, column }) {

    }
});
ParameterTypeDescription
sourceScheduler

The scheduler

menuMenu

The menu

itemsObject<String, MenuItemEntry>

Menu item configs

columnColumn

Time axis column

onContextMenuItemContextMenuBase
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

3
MenuContextContextMenuBase
MenuItemEntryContextMenuBase