class sap.m.MenuItem

Control sample: sap.m.MenuItem
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/m/MenuItem
Application Component: CA-UI5-CTR

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


Constructor

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#constructor for a general description of the syntax of the settings object.

new sap.m.MenuItem(sId?, mSettings?)
Param Type Default Value Description
sId? string

ID for the new control, generated automatically if no ID is given

mSettings? object

Initial settings for the new control


Properties

Name Type Default Value Description
icon string

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

Visibility: public
startsSection boolean false

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

Visibility: public
visible boolean true

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

Visibility: public

Aggregations

Default Aggregation: items

Name Cardinality Type Description
items (default) 0..n sap.m.MenuItem

Defines the sub-items contained within this element.


Events Overview

Event Description
aggregationChanged

Fired when aggregation of the item changes.

press

Fired after the item has been pressed.

propertyChanged

Fired when a property of the item changes.

aggregationChanged

Fired when aggregation of the item changes.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
aggregationName string

The aggregation name of the changed aggregation.

methodName string

Which method changed the aggregation.

methodParams object

What parameters were used to change the aggregation.

press

Fired after the item has been pressed.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object

propertyChanged

Fired when a property of the item changes.

Param Type Description
oControlEvent sap.ui.base.Event
getSource sap.ui.base.EventProvider
getParameters object
propertyKey string

The property name to be changed.

propertyValue any

The new property value.


Methods Overview

Method Description
addItem

Adds some item to the aggregation items.

attachAggregationChanged

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.

attachPress

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.

attachPropertyChanged

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.

bindItems

Binds aggregation items to model data.

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

destroyItems

Destroys all the items in the aggregation items.

detachAggregationChanged

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.

detachPress

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.

detachPropertyChanged

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.

sap.m.MenuItem.extend

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.

fireAggregationChanged

Fires event aggregationChanged to attached listeners.

firePress

Fires event press to attached listeners.

firePropertyChanged

Fires event propertyChanged to attached listeners.

getIcon

Gets current value of property icon.

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

getItems

Gets content of aggregation items.

Defines the sub-items contained within this element.

sap.m.MenuItem.getMetadata

Returns a metadata object for class sap.m.MenuItem.

getStartsSection

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.

getVisible

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.

indexOfItem

Checks for the provided sap.m.MenuItem in the aggregation items. and returns its index if found or -1 otherwise.

insertItem

Inserts a item into the aggregation items.

removeAllItems

Removes all the controls from the aggregation items.

Additionally, it unregisters them from the hosting UIArea.

removeItem

Removes a item from the aggregation items.

setIcon

Sets a new value for property icon.

Defines the icon, which belongs to the item. This can be a 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.

setStartsSection

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.

setVisible

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.

unbindItems

Unbinds aggregation items from model data.

addItem

Adds some item to the aggregation items.

Param Type DefaultValue Description
oItem sap.m.MenuItem

The item to add; if empty, nothing is inserted

attachAggregationChanged

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.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.MenuItem itself

attachPress

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.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.MenuItem itself

attachPropertyChanged

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.

Param Type DefaultValue Description
oData object

An application-specific payload object that will be passed to the event handler along with the event object when firing the event

fnFunction function(sap.ui.base.Event) : void

The function to be called when the event occurs

oListener object

Context object to call the event handler with. Defaults to this sap.m.MenuItem itself

bindItems

Binds aggregation items to model data.

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

Param Type DefaultValue Description
oBindingInfo sap.ui.base.ManagedObject.AggregationBindingInfo

The binding information

destroyItems

Destroys all the items in the aggregation items.

detachAggregationChanged

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.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachPress

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.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

detachPropertyChanged

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.

Param Type DefaultValue Description
fnFunction function(sap.ui.base.Event) : void

The function to be called, when the event occurs

oListener object

Context object on which the given function had to be called

sap.m.MenuItem.extend

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.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

fireAggregationChanged

Fires event aggregationChanged to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

aggregationName string

The aggregation name of the changed aggregation.

methodName string

Which method changed the aggregation.

methodParams object

What parameters were used to change the aggregation.

firePress

Fires event press to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

firePropertyChanged

Fires event propertyChanged to attached listeners.

Param Type DefaultValue Description
mParameters object

Parameters to pass along with the event

propertyKey string

The property name to be changed.

propertyValue any

The new property value.

getIcon

Gets current value of property icon.

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

getItems

Gets content of aggregation items.

Defines the sub-items contained within this element.

sap.m.MenuItem.getMetadata

Returns a metadata object for class sap.m.MenuItem.

getStartsSection

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.

getVisible

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.

indexOfItem

Checks for the provided sap.m.MenuItem in the aggregation items. and returns its index if found or -1 otherwise.

Param Type DefaultValue Description
oItem sap.m.MenuItem

The item whose index is looked for

insertItem

Inserts a item into the aggregation items.

Param Type DefaultValue Description
oItem sap.m.MenuItem

The item to insert; if empty, nothing is inserted

iIndex int

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

removeAllItems

Removes all the controls from the aggregation items.

Additionally, it unregisters them from the hosting UIArea.

removeItem

Removes a item from the aggregation items.

Param Type DefaultValue Description
vItem int string sap.m.MenuItem

The item to remove or its index or id

setIcon

Sets a new value for property icon.

Defines the icon, which belongs to the item. This can be a 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.

Param Type DefaultValue Description
sIcon string

New value for property icon

setStartsSection

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.

Param Type DefaultValue Description
bStartsSection boolean false

New value for property startsSection

setVisible

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.

Param Type DefaultValue Description
bVisible boolean true

New value for property visible

unbindItems

Unbinds aggregation items from model data.