TimeAxisHeaderMenu
Adds scheduler specific menu items to the timeline header context 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() {
// ...
}
}
}
}
}
});
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
Configs
19Other
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.
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;
}
}
},
| Parameter | Type | Description |
|---|---|---|
context | Object | An object with information about the menu being shown. |
context.feature | TimeAxisHeaderMenu | 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.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.
Accessibility
Misc
Properties
20
Properties
20Common
Class hierarchy
Functions
29
Functions
29Configuration
Events
Misc
Other
Events
14
Events
14This 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
items | Object<String, MenuItemEntry> | Menu item configs |
column | Column | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
item | MenuItem | Selected menu item |
column | Column | 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
items | Object<String, MenuItemEntry> | Menu item configs |
column | Column | Time axis column |
Event handlers
14
Event handlers
14This 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
items | Object<String, MenuItemEntry> | Menu item configs |
column | Column | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
item | MenuItem | Selected menu item |
column | Column | 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | Scheduler | The scheduler |
menu | Menu | The menu |
items | Object<String, MenuItemEntry> | Menu item configs |
column | Column | Time axis column |