The MenuItem
control is used for creating items for the sap.m.Menu
. It is derived from a core sap.ui.core.Item
.
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 |
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 |
Default Aggregation: items
Name | Cardinality | Type | Description |
---|---|---|---|
items (default) | 0..n | sap.m.MenuItem |
Defines the sub-items contained within this element. |
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. |
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. |
Method | Description |
---|---|
addItem |
Adds some item to the aggregation items. |
attachAggregationChanged |
Attaches event handler When called, the context of the event handler (its Fired when aggregation of the item changes. |
attachPress |
Attaches event handler When called, the context of the event handler (its Fired after the item has been pressed. |
attachPropertyChanged |
Attaches event handler When called, the context of the event handler (its 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 |
destroyItems |
Destroys all the items in the aggregation items. |
detachAggregationChanged |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachPress |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachPropertyChanged |
Detaches event handler 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
|
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 |
getVisible |
Gets current value of property visible. Defines whether the item should be visible on the screen. If set to Default value is |
indexOfItem |
Checks for the provided |
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 |
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 Default value is |
setVisible |
Sets a new value for property visible. Defines whether the item should be visible on the screen. If set to When called with a value of Default value is |
unbindItems |
Unbinds aggregation items from model data. |
Adds some item to the aggregation items.
Param | Type | DefaultValue | Description |
---|---|---|---|
oItem | sap.m.MenuItem |
The item to add; if empty, nothing is inserted |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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. |
Fires event press to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
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. |
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.
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
.
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
.
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 |
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 |
Removes all the controls from the aggregation items.
Additionally, it unregisters them from the hosting UIArea.
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 |
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 |
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 |
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 |