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

Common

listenersEvents

Other

checked: Boolean | StringAlso a property

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
        }
    }
}
closeParent: Boolean

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

href: String

If provided, turns the menu item into a link

icon: String

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.

A submenu configuration object, or an array of MenuItem configuration objects from which to create a submenu.

Configuration object example:

new Menu({
    // Menu items
    items : {
        move : {
            text : 'Main item',
            menu : {
                // Submenu items
                firstItem : {
                    text : 'Sub-item 1',
                    onItem({ eventRecord }) {}
                },
                secondItem : {
                    text : 'Sub-item 2',
                    onItem({ eventRecord }) {}
                }
            }
        }
    }
});

Array of items example:

new Menu({
    // Menu items
    items : {
        move : {
            text : 'Main item',
            // Submenu items
            menu : [
                {
                    text : 'Sub-item 1',
                    onItem({ eventRecord }) {}
                },
                {
                    text : 'Sub-item 2',
                    onItem({ eventRecord }) {}
                }
            ]
        }
    }
});

Note that this does not have to be a Menu. The type config can be used to specify any widget as the submenu.

new Menu({
    // Menu items
    items : {
        move : {
            text : 'Main item',
            // Submenu items
            menu : [
                {
                    type  : 'textfield',
                    label : 'Type here'
                },
                {
                    type : 'button',
                    text : 'Confirm'
                }
            ]
        }
    }
});
separator: Boolean= false

Set to true to display a border above this menu item, if there are other visible menu items before it.

The target attribute for the href config

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'
});
columnWidget
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

CSS

clsWidget
colorWidget
htmlClsWidget
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

Misc

dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Scrolling

Properties

69

Class hierarchy

isMenuItem: Boolean= truereadonly
Identifies an object as an instance of MenuItem class, or subclass thereof.
isMenuItem: Boolean= truereadonlystatic
Identifies an object as an instance of MenuItem class, or subclass thereof.
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isWidgetWidget

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.

Returns the instantiated menu widget as configured by menu.

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'
});
$namestaticWidget
columnWidget
rtlRTL
spanWidget
typestaticWidget

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
tooltipWidget

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget

Functions

59

Other

Actions this item. Fires the item event, and if this is a checked item, toggles the checked state, firing the toggle event.

composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
triggerEvents
unEvents
unmaskWidget

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

16

This 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 }) => {

});
ParameterTypeDescription
itemMenuItem

The menu item which is being actioned.

menuMenu

Menu containing the menu item

domEventEvent

The user interaction event

recordModel

Current record if called from Grid

columnModel

Current column if called from Grid

columnRecordModel

Current column if called from TaskBoard

taskRecordModel

Current record if called from TaskBoard or Gantt

eventRecordModel

Current event if called from Scheduler or SchedulerPro or Calendar

resourceRecordModel

Current resource if called from Scheduler or SchedulerPro or a resource-bound Calendar view

assignmentRecordModel

Current assignment if called from Scheduler or SchedulerPro or a resource-bound Calendar view

dateDate

The clicked date when called from ScheduleMenu belonging to Scheduler or SchedulerPro

checkedBoolean

Current checked state for item which had checked config

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 }) => {

});
ParameterTypeDescription
itemMenuItem

The menu item whose checked state changed.

menuMenu

Menu containing the menu item

checkedBoolean

The new checked state.

catchAllEvents
destroyEvents
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

16

This 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 }) {

    }
});
ParameterTypeDescription
itemMenuItem

The menu item which is being actioned.

menuMenu

Menu containing the menu item

domEventEvent

The user interaction event

recordModel

Current record if called from Grid

columnModel

Current column if called from Grid

columnRecordModel

Current column if called from TaskBoard

taskRecordModel

Current record if called from TaskBoard or Gantt

eventRecordModel

Current event if called from Scheduler or SchedulerPro or Calendar

resourceRecordModel

Current resource if called from Scheduler or SchedulerPro or a resource-bound Calendar view

assignmentRecordModel

Current assignment if called from Scheduler or SchedulerPro or a resource-bound Calendar view

dateDate

The clicked date when called from ScheduleMenu belonging to Scheduler or SchedulerPro

checkedBoolean

Current checked state for item which had checked config

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 }) {

    }
});
ParameterTypeDescription
itemMenuItem

The menu item whose checked state changed.

menuMenu

Menu containing the menu item

checkedBoolean

The new checked state.

onDestroyEvents
onFocusInWidget
onHideWidget
onPaintWidget
onResizeWidget
onShowWidget

Typedefs

6

CSS variables

40
NameDescription
--b-menu-item-gapGap between menu item parts (icon, text, sub-menu icon)
--b-menu-item-icon-widthMenu icon width, to make sure everything lines up nicely
--b-menu-item-min-widthMinimum width of a menu item
--b-menu-item-paddingMenu item padding
--b-menu-item-font-weightMenu item font-weight
--b-menu-item-separator-border-colorSeparator item color
--b-menu-item-colorMenu item color
--b-menu-item-icon-colorColor for menu item's icon
--b-menu-item-backgroundMenu item background
--b-menu-item-border-radiusMenu item border radius
--b-menu-item-separator-heightHeight of the separator
--b-menu-item-separator-insetInset-inline for the separator
Disabled
--b-menu-item-disabled-colorColor for disabled menu item
--b-menu-item-disabled-icon-colorColor for disabled menu item's icon
Focused
--b-menu-item-focus-colorColor for menu item when focused
--b-menu-item-focus-icon-colorColor for menu item's icon when hovering the item
--b-menu-item-focus-backgroundBackground for focused menu item
Hovered
--b-menu-item-hover-colorColor for menu item when hovering it
--b-menu-item-hover-icon-colorColor for menu item's icon when hovering the item
--b-menu-item-hover-backgroundBackground for hovered menu item

Inherited