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.
Event Summary
press(oControlEvent)Fired after the item has been pressed. 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
. 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
. firePress(mArguments?)Fires event press
to attached listeners. getIcon()Gets current value of property icon
. getItems()Gets content of aggregation items
. 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
. removeItem(vItem)Removes a item from the aggregation items
. setIcon(sIcon)Sets a new value for property icon
. setVisible(bVisible)Sets a new value for property visible
. unbindItems()Unbinds aggregation items
from model data. $,
addCustomData,
addDependent,
addEventDelegate,
applyFocusInfo,
bindElement,
clone,
data,
destroy,
destroyCustomData,
destroyDependents,
destroyLayoutData,
destroyTooltip,
enhanceAccessibilityState,
exit,
findElements,
fireEvent,
focus,
getCustomData,
getDependents,
getDomRef,
getElementBinding,
getFocusDomRef,
getFocusInfo,
getInterface,
getLayoutData,
getMetadata,
getTooltip,
getTooltip_AsString,
getTooltip_Text,
indexOfCustomData,
indexOfDependent,
init,
insertCustomData,
insertDependent,
prop,
removeAllCustomData,
removeAllDependents,
removeCustomData,
removeDependent,
removeEventDelegate,
rerender,
setLayoutData,
setTooltip,
toString,
unbindElement addAggregation,
addAssociation,
applySettings,
attachFormatError,
attachModelContextChange,
attachParseError,
attachValidationError,
attachValidationSuccess,
bindAggregation,
bindContext,
bindObject,
bindProperty,
destroyAggregation,
detachFormatError,
detachModelContextChange,
detachParseError,
detachValidationError,
detachValidationSuccess,
findAggregatedObjects,
fireFormatError,
fireModelContextChange,
fireParseError,
fireValidationError,
fireValidationSuccess,
getAggregation,
getAssociation,
getBinding,
getBindingContext,
getBindingInfo,
getBindingPath,
getEventingParent,
getId,
getModel,
getObjectBinding,
getOriginInfo,
getParent,
getProperty,
hasModel,
indexOfAggregation,
insertAggregation,
invalidate,
isBound,
isInvalidateSuppressed,
isTreeBinding,
propagateMessages,
removeAggregation,
removeAllAggregation,
removeAllAssociation,
removeAssociation,
setAggregation,
setAssociation,
setBindingContext,
setModel,
setProperty,
unbindAggregation,
unbindContext,
unbindObject,
unbindProperty,
validateAggregation,
validateProperty 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:
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 |
Returns a metadata object for class sap.m.MenuItem.
Returns:
Adds some item to the aggregation items
.
Parameters:
Returns:
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:
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:
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:
Parameters:
{object} | oBindingInfo | The binding information |
Returns:
Destroys all the items in the aggregation items
.
Returns:
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:
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:
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:
Fires event
aggregationChanged
to attached listeners.
Expects the following event parameters:
aggregationName
of type String
The aggregation name of the changed aggregation.methodName
of type String
Which method changed the aggregation.methodParams
of type Object
What parameters were used to change the aggregation.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
Fires event press
to attached listeners.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
Fires event
propertyChanged
to attached listeners.
Expects the following event parameters:
propertyKey
of type string
The property name to be changed.propertyValue
of type mixed
The new property value.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
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 |
Gets content of aggregation
items
.
Defines the sub-items contained within this element.
Returns:
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:
Returns:
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
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:
Removes all the controls from the aggregation
items
.
Additionally, it unregisters them from the hosting UIArea.
Returns:
Removes a item from the aggregation items
.
Parameters:
Returns:
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:
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:
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:
Unbinds aggregation items
from model data.
Returns: