The sap.m.Menu
control represents a hierarchical menu. When opened on mobile devices it occupies the whole screen.
Note: The application developer should add dependency to sap.ui.unified
library on application level to ensure that the library is loaded before the module dependencies will be required. If the sap.ui.unified
library is not loaded in advance, this could lead to CSP compliance issues and adds an additional waiting time. To prevent this, ensure that the sap.ui.unified
library is loaded in advance.
Constructor for a new Menu.
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.Menu(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 |
Default Aggregation: items
Name | Cardinality | Type | Description |
---|---|---|---|
_dialog | 0..1 | sap.m.Dialog |
Internal aggregation that contains the inner |
_menu | 0..1 | sap.ui.unified.Menu |
Internal aggregation that contains the inner |
items (default) | 0..n | sap.m.MenuItem |
Defines the items contained within this control. |
Event | Description |
---|---|
closed |
Fired when the menu is closed. |
itemSelected |
Fired when a |
Method | Description |
---|---|
addItem |
Adds some item to the aggregation items. |
attachClosed |
Attaches event handler When called, the context of the event handler (its Fired when the menu is closed. |
attachItemSelected |
Attaches event handler When called, the context of the event handler (its Fired when a |
bindItems |
Binds aggregation items to model data. See ManagedObject.bindAggregation for a detailed description of the possible properties of |
close |
Closes the |
destroyItems |
Destroys all the items in the aggregation items. |
detachClosed |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
detachItemSelected |
Detaches event handler The passed function and listener object must match the ones used for event registration. |
sap.m.Menu.extend |
Creates a new subclass of class sap.m.Menu with name
|
fireClosed |
Fires event closed to attached listeners. |
fireItemSelected |
Fires event itemSelected to attached listeners. |
getItems |
Gets content of aggregation items. Defines the items contained within this control. |
sap.m.Menu.getMetadata |
Returns a metadata object for class sap.m.Menu. |
getTitle |
Gets current value of property title. Defines the |
indexOfItem |
Checks for the provided |
init |
Initializes the control. |
insertItem |
Inserts a item into the aggregation items. |
openAsContextMenu |
Opens the menu as a context menu. |
openBy |
Opens the |
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. |
setTitle |
Sets the title of the |
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 closed event of this sap.m.Menu
.
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.Menu
itself.
Fired when the menu is closed.
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 itemSelected event of this sap.m.Menu
.
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.Menu
itself.
Fired when a MenuItem
is selected.
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 closed event of this sap.m.Menu
.
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 itemSelected event of this sap.m.Menu
.
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.Menu 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.Control.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 closed to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
Fires event itemSelected to attached listeners.
Param | Type | DefaultValue | Description |
---|---|---|---|
mParameters | object |
Parameters to pass along with the event |
|
item | sap.m.MenuItem |
The |
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 |
Opens the menu as a context menu.
Param | Type | DefaultValue | Description |
---|---|---|---|
oEvent | jQuery.Event object |
The event object or an object containing offsetX, offsetY values and left, top values of the element's position |
|
oOpenerRef | sap.ui.core.Element HTMLElement |
The reference of the opener |
Opens the Menu
next to the given control.
Param | Type | DefaultValue | Description |
---|---|---|---|
oControl | object |
The control that defines the position for the menu |
|
bWithKeyboard | boolean |
Whether the menu is opened with a shortcut or not |
|
sDockMy | sap.ui.core.Dock | sap.ui.core.Popup.Dock.BeginTop |
The reference docking location of the |
sDockAt | sap.ui.core.Dock | sap.ui.core.Popup.Dock.BeginBottom |
The |
sOffset | string | "0 -2" |
The offset relative to the docking point, specified as a string with space-separated pixel values (e.g. "0 10" to move the popup 10 pixels to the right). If the docking of both "my" and "at" is RTL-sensitive ("begin" or "end"), this offset is automatically mirrored in the RTL case as well. |
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 |