MenuItem
A widget representing a single menu item in a Menu. May be configured with a checked state which creates a checkbox which may be toggled. Can also be disabled, which affects item appearance and blocks interactions.
Fires events when activated which bubble up through the parent hierarchy and may be listened for on an ancestor. See Menu for more details on usage.
To add a border above a menu item, you can set separator to true. The separator is automatically
hidden if the menu item is the first visible item in the menu.
Configs
83
Configs
83Common
Other
If configured with a Boolean value, a checkbox is displayed
as the start icon, and the toggle event is fired
when the checked state changes.
String value allows to link value by reference name.
Example:
menu : {
items : {
fill : {
text : 'Fill width',
checked : 'up.resourceColumns.fillWidth'
},
fit : {
text : 'Fit width',
checked : false,
closeParent : true
}
}
}
By default, upon activate, non-checkbox menu items will collapse the owning menu hierarchy.
Configure this as false to cause the menu to persist after
activating an item
If provided, turns the menu item into a link
Item icon class.
All Font Awesome icons may also be specified as 'fa-' + iconName.
Otherwise this is a developer-defined CSS class string which results in the desired icon.
Set to true to display a border above this menu item, if there are other visible menu items before it.
The text to be displayed in the item. The text is automatically HTML encoded.
Indicates that this menu item is part of a group where only one can be checked. Assigning a value
also sets toggleable to true.
const yesButton = new Button({
toggleGroup : 'yesno',
text : 'Yes'
});
const noButton = new Button({
toggleGroup : 'yesno',
text : 'No'
});
DOM
Float & align
Layout
Misc
Scrolling
Properties
69
Properties
69Class hierarchy
Other
Get/sets the checked state of this MenuItem and fires the toggle
event upon change.
Note that this must be configured as a Boolean to enable the checkbox UI.
The text to be displayed in the item. The text is automatically HTML encoded.
Indicates that this menu item is part of a group where only one can be checked. Assigning a value
also sets toggleable to true.
const yesButton = new Button({
toggleGroup : 'yesno',
text : 'Yes'
});
const noButton = new Button({
toggleGroup : 'yesno',
text : 'No'
});
CSS
DOM
Layout
Misc
Functions
59
Functions
59Other
Configuration
Events
Misc
Widget hierarchy
Events
16
Events
16This menu item has been activated.
Note that this event bubbles up through parents and can be listened for on a top level Menu for convenience.
// Adding a listener using the "on" method
menuItem.on('item', ({ item, menu, domEvent, record, column, columnRecord, taskRecord, eventRecord, resourceRecord, assignmentRecord, date, checked }) => {
});| Parameter | Type | Description |
|---|---|---|
item | MenuItem | The menu item which is being actioned. |
menu | Menu | Menu containing the menu item |
domEvent | Event | The user interaction event |
record | Model | Current record if called from Grid |
column | Model | Current column if called from Grid |
columnRecord | Model | Current column if called from TaskBoard |
taskRecord | Model | Current record if called from TaskBoard or Gantt |
eventRecord | Model | Current event if called from Scheduler or SchedulerPro or Calendar |
resourceRecord | Model | Current resource if called from Scheduler or SchedulerPro or a resource-bound Calendar view |
assignmentRecord | Model | Current assignment if called from Scheduler or SchedulerPro or a resource-bound Calendar view |
date | Date | The clicked date when called from ScheduleMenu belonging to Scheduler or SchedulerPro |
checked | Boolean | Current checked state for item which had |
The checked state of this menu item has changed.
Note that this event bubbles up through parents and can be listened for on a top level Menu for convenience.
// Adding a listener using the "on" method
menuItem.on('toggle', ({ item, menu, checked }) => {
});| Parameter | Type | Description |
|---|---|---|
item | MenuItem | The menu item whose checked state changed. |
menu | Menu | Menu containing the menu item |
checked | Boolean | The new checked state. |
Event handlers
16
Event handlers
16This menu item has been activated.
Note that this event bubbles up through parents and can be listened for on a top level Menu for convenience.
new MenuItem({
onItem({ item, menu, domEvent, record, column, columnRecord, taskRecord, eventRecord, resourceRecord, assignmentRecord, date, checked }) {
}
});| Parameter | Type | Description |
|---|---|---|
item | MenuItem | The menu item which is being actioned. |
menu | Menu | Menu containing the menu item |
domEvent | Event | The user interaction event |
record | Model | Current record if called from Grid |
column | Model | Current column if called from Grid |
columnRecord | Model | Current column if called from TaskBoard |
taskRecord | Model | Current record if called from TaskBoard or Gantt |
eventRecord | Model | Current event if called from Scheduler or SchedulerPro or Calendar |
resourceRecord | Model | Current resource if called from Scheduler or SchedulerPro or a resource-bound Calendar view |
assignmentRecord | Model | Current assignment if called from Scheduler or SchedulerPro or a resource-bound Calendar view |
date | Date | The clicked date when called from ScheduleMenu belonging to Scheduler or SchedulerPro |
checked | Boolean | Current checked state for item which had |
The checked state of this menu item has changed.
Note that this event bubbles up through parents and can be listened for on a top level Menu for convenience.
new MenuItem({
onToggle({ item, menu, checked }) {
}
});| Parameter | Type | Description |
|---|---|---|
item | MenuItem | The menu item whose checked state changed. |
menu | Menu | Menu containing the menu item |
checked | Boolean | The new checked state. |
Typedefs
6
Typedefs
6CSS variables
40
CSS variables
40| Name | Description |
|---|---|
--b-menu-item-gap | Gap between menu item parts (icon, text, sub-menu icon) |
--b-menu-item-icon-width | Menu icon width, to make sure everything lines up nicely |
--b-menu-item-min-width | Minimum width of a menu item |
--b-menu-item-padding | Menu item padding |
--b-menu-item-font-weight | Menu item font-weight |
--b-menu-item-separator-border-color | Separator item color |
--b-menu-item-color | Menu item color |
--b-menu-item-icon-color | Color for menu item's icon |
--b-menu-item-background | Menu item background |
--b-menu-item-border-radius | Menu item border radius |
--b-menu-item-separator-height | Height of the separator |
--b-menu-item-separator-inset | Inset-inline for the separator |
| Disabled | |
--b-menu-item-disabled-color | Color for disabled menu item |
--b-menu-item-disabled-icon-color | Color for disabled menu item's icon |
| Focused | |
--b-menu-item-focus-color | Color for menu item when focused |
--b-menu-item-focus-icon-color | Color for menu item's icon when hovering the item |
--b-menu-item-focus-background | Background for focused menu item |
| Hovered | |
--b-menu-item-hover-color | Color for menu item when hovering it |
--b-menu-item-hover-icon-color | Color for menu item's icon when hovering the item |
--b-menu-item-hover-background | Background for hovered menu item |