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;
}
}
}
}
});
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
Configs
18Other
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:
addEventAdd an event for at the resource and time indicated by thecontextmenuevent.
To remove existing items, set corresponding keys null:
const scheduler = new Scheduler({
features : {
scheduleMenu : {
items : {
addEvent : null
}
}
}
});
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;
}
}
}
},
| Parameter | Type | Description |
|---|---|---|
context | Object | An object with information about the menu being shown |
context.feature | ScheduleMenu | A reference to this feature. |
context.domEvent | Event | The initiating event. |
context.event | Event | DEPRECATED: The initiating event. |
context.point | Number[] | The client |
context.targetElement | HTMLElement | The target to which the menu is being applied. |
context.resourceRecord | ResourceModel | The record representing the current resource |
context.date | Date | The clicked date |
context.items | Object<String, MenuItemEntry> | An object containing the menu item configs keyed by their id. |
Returning false from this function prevents the menu being shown
Misc
Properties
20
Properties
20Common
Class hierarchy
Functions
29
Functions
29Configuration
Events
Misc
Other
Events
10
Events
10This 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
items | Object<String, MenuItemEntry> | Menu item configs |
resourceRecord | ResourceModel | Resource record |
date | Date | Clicked date, rounded according to viewPreset's settings |
assignmentRecord | AssignmentModel | Assignment record, if assignments are used |
eventElement | HTMLElement |
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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
item | MenuItem | |
resourceRecord | ResourceModel | |
date | Date | Clicked date, rounded according to viewPreset's settings |
element | HTMLElement |
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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
items | Object<String, MenuItemEntry> | Menu item configs |
menu | Menu | The menu |
resourceRecord | ResourceModel | |
date | Date | Clicked date, rounded according to viewPreset's settings |
targetElement | HTMLElement |
Event handlers
10
Event handlers
10This 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
items | Object<String, MenuItemEntry> | Menu item configs |
resourceRecord | ResourceModel | Resource record |
date | Date | Clicked date, rounded according to viewPreset's settings |
assignmentRecord | AssignmentModel | Assignment record, if assignments are used |
eventElement | HTMLElement |
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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
item | MenuItem | |
resourceRecord | ResourceModel | |
date | Date | Clicked date, rounded according to viewPreset's settings |
element | HTMLElement |
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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | |
items | Object<String, MenuItemEntry> | Menu item configs |
menu | Menu | The menu |
resourceRecord | ResourceModel | |
date | Date | Clicked date, rounded according to viewPreset's settings |
targetElement | HTMLElement |