Class sap.m.MenuItemModule: sap/m/MenuItem

extends Item

The MenuItem control is used for creating items for the sap.m.Menu. It is derived from a core sap.ui.core.Item.


Since: 1.38.
Constructor Summary
new sap.m.MenuItem(sId?, mSettings?)Constructor for a new MenuItem.
Event Summary
aggregationChanged(oControlEvent)Fired when aggregation of the item changes.
press(oControlEvent)Fired after the item has been pressed.
propertyChanged(oControlEvent)Fired when a property of the item changes.
Method Summary
sap.m.MenuItem.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.MenuItem with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.MenuItem.getMetadata()Returns a metadata object for class sap.m.MenuItem.
addItem(oItem)Adds some item to the aggregation items.
attachAggregationChanged(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the aggregationChanged event of this sap.m.MenuItem.
attachPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the press event of this sap.m.MenuItem.
attachPropertyChanged(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the propertyChanged event of this sap.m.MenuItem.
bindItems(oBindingInfo)Binds aggregation items to model data.
destroyItems()Destroys all the items in the aggregation items.
detachAggregationChanged(fnFunction, oListener)Detaches event handler fnFunction from the aggregationChanged event of this sap.m.MenuItem.
detachPress(fnFunction, oListener)Detaches event handler fnFunction from the press event of this sap.m.MenuItem.
detachPropertyChanged(fnFunction, oListener)Detaches event handler fnFunction from the propertyChanged event of this sap.m.MenuItem.
fireAggregationChanged(mArguments?)Fires event aggregationChanged to attached listeners.
firePress(mArguments?)Fires event press to attached listeners.
firePropertyChanged(mArguments?)Fires event propertyChanged to attached listeners.
getIcon()Gets current value of property icon.
getItems()Gets content of aggregation items.
getStartsSection()Gets current value of property startsSection.
getVisible()Gets current value of property visible.
indexOfItem(oItem)Checks for the provided sap.m.MenuItem in the aggregation items.
insertItem(oItem, iIndex)Inserts a item into the aggregation items.
removeAllItems()Removes all the controls from the aggregation items.
removeItem(vItem)Removes a item from the aggregation items.
setIcon(sIcon)Sets a new value for property icon.
setStartsSection(bStartsSection)Sets a new value for property startsSection.
setVisible(bVisible)Sets a new value for property visible.
unbindItems()Unbinds aggregation items from model data.
Constructor Detail
new sap.m.MenuItem(sId?, mSettings?)
Constructor for a new MenuItem.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties
  • Aggregations
    • items : sap.m.MenuItem[] (default)
  • Events
    • press : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • propertyChanged : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • aggregationChanged : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Item can be used as well.

Parameters:
{string}sId? ID for the new control, generated automatically if no ID is given
{object}mSettings? Initial settings for the new control
Event Detail
aggregationChanged(oControlEvent)
Fired when aggregation of the item changes.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{String}oControlEvent.getParameters.aggregationName The aggregation name of the changed aggregation.
{String}oControlEvent.getParameters.methodName Which method changed the aggregation.
{Object}oControlEvent.getParameters.methodParams What parameters were used to change the aggregation.
press(oControlEvent)
Fired after the item has been pressed.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
propertyChanged(oControlEvent)
Fired when a property of the item changes.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.propertyKey The property name to be changed.
{mixed}oControlEvent.getParameters.propertyValue The new property value.
Method Detail
sap.m.MenuItem.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.MenuItem with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Item.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.MenuItem.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.MenuItem.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addItem(oItem): sap.m.MenuItem
Adds some item to the aggregation items.
Parameters:
{sap.m.MenuItem}oItem the item to add; if empty, nothing is inserted
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
attachAggregationChanged(oData?, fnFunction, oListener?): sap.m.MenuItem
Attaches event handler fnFunction to the aggregationChanged event of this sap.m.MenuItem.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.MenuItem itself.

Fired when aggregation of the item changes.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.MenuItem itself
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
attachPress(oData?, fnFunction, oListener?): sap.m.MenuItem
Attaches event handler fnFunction to the press event of this sap.m.MenuItem.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.MenuItem itself.

Fired after the item has been pressed.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.MenuItem itself
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
attachPropertyChanged(oData?, fnFunction, oListener?): sap.m.MenuItem
Attaches event handler fnFunction to the propertyChanged event of this sap.m.MenuItem.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.MenuItem itself.

Fired when a property of the item changes.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.MenuItem itself
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
bindItems(oBindingInfo): sap.m.MenuItem
Binds aggregation items to model data.

See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo.

Parameters:
{object}oBindingInfo The binding information
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
destroyItems(): sap.m.MenuItem
Destroys all the items in the aggregation items.
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
detachAggregationChanged(fnFunction, oListener): sap.m.MenuItem
Detaches event handler fnFunction from the aggregationChanged event of this sap.m.MenuItem.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
detachPress(fnFunction, oListener): sap.m.MenuItem
Detaches event handler fnFunction from the press event of this sap.m.MenuItem.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
detachPropertyChanged(fnFunction, oListener): sap.m.MenuItem
Detaches event handler fnFunction from the propertyChanged event of this sap.m.MenuItem.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
fireAggregationChanged(mArguments?): sap.m.MenuItem
Fires event aggregationChanged to attached listeners.

Expects the following event parameters:

  • aggregationName of type StringThe aggregation name of the changed aggregation.
  • methodName of type StringWhich method changed the aggregation.
  • methodParams of type ObjectWhat parameters were used to change the aggregation.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
firePress(mArguments?): sap.m.MenuItem
Fires event press to attached listeners.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
firePropertyChanged(mArguments?): sap.m.MenuItem
Fires event propertyChanged to attached listeners.

Expects the following event parameters:

  • propertyKey of type stringThe property name to be changed.
  • propertyValue of type mixedThe new property value.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
getIcon(): string
Gets current value of property icon.

Defines the icon, which belongs to the item. This can be an URI to an image or an icon font URI.

Returns:
{string} Value of property icon
getItems(): sap.m.MenuItem[]
Gets content of aggregation items.

Defines the sub-items contained within this element.

Returns:
{sap.m.MenuItem[]}
getStartsSection(): boolean
Gets current value of property startsSection.

Defines whether a visual separator should be rendered before the item. Note: If an item is invisible its separator is also not displayed.

Default value is false.

Returns:
{boolean} Value of property startsSection
getVisible(): boolean
Gets current value of property visible.

Defines whether the item should be visible on the screen. If set to false, a placeholder is rendered instead of the real item.

Default value is true.

Returns:
{boolean} Value of property visible
indexOfItem(oItem): int
Checks for the provided sap.m.MenuItem in the aggregation items. and returns its index if found or -1 otherwise.
Parameters:
{sap.m.MenuItem}oItem The item whose index is looked for
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertItem(oItem, iIndex): sap.m.MenuItem
Inserts a item into the aggregation items.
Parameters:
{sap.m.MenuItem}oItem the item to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the item should be inserted at; for a negative value of iIndex, the item is inserted at position 0; for a value greater than the current size of the aggregation, the item is inserted at the last position
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
removeAllItems(): sap.m.MenuItem[]
Removes all the controls from the aggregation items.

Additionally, it unregisters them from the hosting UIArea.

Returns:
{sap.m.MenuItem[]} An array of the removed elements (might be empty)
removeItem(vItem): sap.m.MenuItem
Removes a item from the aggregation items.
Parameters:
{int|string|sap.m.MenuItem}vItem The itemto remove or its index or id
Returns:
{sap.m.MenuItem} The removed item or null
setIcon(sIcon): sap.m.MenuItem
Sets a new value for property icon.

Defines the icon, which belongs to the item. This can be an URI to an image or an icon font URI.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sIcon New value for property icon
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
setStartsSection(bStartsSection): sap.m.MenuItem
Sets a new value for property startsSection.

Defines whether a visual separator should be rendered before the item. Note: If an item is invisible its separator is also not displayed.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Parameters:
{boolean}bStartsSection New value for property startsSection
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
setVisible(bVisible): sap.m.MenuItem
Sets a new value for property visible.

Defines whether the item should be visible on the screen. If set to false, a placeholder is rendered instead of the real item.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Parameters:
{boolean}bVisible New value for property visible
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining
unbindItems(): sap.m.MenuItem
Unbinds aggregation items from model data.
Returns:
{sap.m.MenuItem} Reference to this in order to allow method chaining