Class sap.m.ActionSheetModule: sap/m/ActionSheet

extends Control

The action sheet holds a list of options from which the user can select to complete an action.

Overview

The options of the action sheet are represented as buttons with icons. Elements in the action sheet are left-aligned. Actions should be arranged in order of importance, from top to bottom.

Guidelines

  • Always display text or text and icons for the actions. Do not use icons only.
  • Always provide a Cancel button on mobile phones.
  • Avoid scrolling on action sheets.

Responsive Behavior

On mobile phones the action sheet is displayed in a dialog.

On tablets and desktop the action sheet is displayed in a popover.

When an action is triggered, the action sheet closes and you can display a confirmation as a message toast.


Since: 1.9.1.
Constructor Summary
new sap.m.ActionSheet(sId?, mSettings?)Constructor for a new ActionSheet.
Event Summary
afterClose(oControlEvent)This event will be fired after the ActionSheet is closed.
afterOpen(oControlEvent)This event will be fired after the ActionSheet is opened.
beforeClose(oControlEvent)This event will be fired before the ActionSheet is closed.
beforeOpen(oControlEvent)This event will be fired before the ActionSheet is opened.
cancelButtonPress(oControlEvent)This event is fired when the cancelButton is clicked.
cancelButtonTap(oControlEvent)This event is fired when the cancelButton is tapped.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.ActionSheet.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.ActionSheet with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.ActionSheet.getMetadata()Returns a metadata object for class sap.m.ActionSheet.
addButton(oButton)Adds some button to the aggregation buttons.
attachAfterClose(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the afterClose event of this sap.m.ActionSheet.
attachAfterOpen(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the afterOpen event of this sap.m.ActionSheet.
attachBeforeClose(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the beforeClose event of this sap.m.ActionSheet.
attachBeforeOpen(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the beforeOpen event of this sap.m.ActionSheet.
attachCancelButtonPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the cancelButtonPress event of this sap.m.ActionSheet.
close()Calling this method will make the ActionSheet disappear from the screen.
destroyButtons()Destroys all the buttons in the aggregation buttons.
detachAfterClose(fnFunction, oListener)Detaches event handler fnFunction from the afterClose event of this sap.m.ActionSheet.
detachAfterOpen(fnFunction, oListener)Detaches event handler fnFunction from the afterOpen event of this sap.m.ActionSheet.
detachBeforeClose(fnFunction, oListener)Detaches event handler fnFunction from the beforeClose event of this sap.m.ActionSheet.
detachBeforeOpen(fnFunction, oListener)Detaches event handler fnFunction from the beforeOpen event of this sap.m.ActionSheet.
detachCancelButtonPress(fnFunction, oListener)Detaches event handler fnFunction from the cancelButtonPress event of this sap.m.ActionSheet.
fireAfterClose(mParameters?)Fires event afterClose to attached listeners.
fireAfterOpen(mParameters?)Fires event afterOpen to attached listeners.
fireBeforeClose(mParameters?)Fires event beforeClose to attached listeners.
fireBeforeOpen(mParameters?)Fires event beforeOpen to attached listeners.
fireCancelButtonPress(mParameters?)Fires event cancelButtonPress to attached listeners.
getButtons()Gets content of aggregation buttons.
getCancelButtonText()Gets current value of property cancelButtonText.
getPlacement()Gets current value of property placement.
getPopupHiddenLabelId()Gets the ID of the hidden label
getShowCancelButton()Gets current value of property showCancelButton.
getTitle()Gets current value of property title.
indexOfButton(oButton)Checks for the provided sap.m.Button in the aggregation buttons.
insertButton(oButton, iIndex)Inserts a button into the aggregation buttons.
isOpen()The method checks if the ActionSheet is open.
openBy(oControl)Calling this method will make the ActionSheet visible on the screen.
removeAllButtons()Removes all the controls from the aggregation buttons.
removeButton(vButton)Removes a button from the aggregation buttons.
setCancelButtonText(sCancelButtonText)Sets a new value for property cancelButtonText.
setPlacement(sPlacement)Sets a new value for property placement.
setShowCancelButton(bShowCancelButton)Sets a new value for property showCancelButton.
setTitle(sTitle)Sets a new value for property title.
attachCancelButtonTap(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the cancelButtonTap event of this sap.m.ActionSheet.
detachCancelButtonTap(fnFunction, oListener)Detaches event handler fnFunction from the cancelButtonTap event of this sap.m.ActionSheet.
fireCancelButtonTap(mParameters?)Fires event cancelButtonTap to attached listeners.
Constructor Detail
new sap.m.ActionSheet(sId?, mSettings?)

Constructor for a new ActionSheet.

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

  • Events

    • cancelButtonTap : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • beforeOpen : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • afterOpen : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • beforeClose : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • afterClose : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • cancelButtonPress : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

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

Parameters:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?Initial settings for the new control
Event Detail
afterClose(oControlEvent)
This event will be fired after the ActionSheet is closed.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
afterOpen(oControlEvent)
This event will be fired after the ActionSheet is opened.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
beforeClose(oControlEvent)
This event will be fired before the ActionSheet is closed.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
beforeOpen(oControlEvent)
This event will be fired before the ActionSheet is opened.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
cancelButtonPress(oControlEvent)
This event is fired when the cancelButton is clicked. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by clicking outside.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
cancelButtonTap(oControlEvent)
This event is fired when the cancelButton is tapped. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by tapping outside.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
Deprecated API:
Since version 1.20.0. This event is deprecated, use the cancelButtonPress event instead.
Method Detail
sap.m.ActionSheet.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.m.ActionSheet 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.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.m.ActionSheet.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.ActionSheet.
Returns:
sap.ui.base.MetadataMetadata object describing this class
addButton(oButton): sap.m.ActionSheet
Adds some button to the aggregation buttons.
Parameters:
sap.m.ButtonoButtonthe button to add; if empty, nothing is inserted
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachAfterClose(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the afterClose event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event will be fired after the ActionSheet is closed.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachAfterOpen(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the afterOpen event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event will be fired after the ActionSheet is opened.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachBeforeClose(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the beforeClose event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event will be fired before the ActionSheet is closed.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachBeforeOpen(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the beforeOpen event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event will be fired before the ActionSheet is opened.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachCancelButtonPress(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the cancelButtonPress event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event is fired when the cancelButton is clicked. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by clicking outside.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
close(): void
Calling this method will make the ActionSheet disappear from the screen.
destroyButtons(): sap.m.ActionSheet
Destroys all the buttons in the aggregation buttons.
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
detachAfterClose(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the afterClose event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
detachAfterOpen(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the afterOpen event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
detachBeforeClose(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the beforeClose event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
detachBeforeOpen(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the beforeOpen event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
detachCancelButtonPress(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the cancelButtonPress event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
fireAfterClose(mParameters?): sap.m.ActionSheet
Fires event afterClose to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
fireAfterOpen(mParameters?): sap.m.ActionSheet
Fires event afterOpen to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
fireBeforeClose(mParameters?): sap.m.ActionSheet
Fires event beforeClose to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
fireBeforeOpen(mParameters?): sap.m.ActionSheet
Fires event beforeOpen to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
fireCancelButtonPress(mParameters?): sap.m.ActionSheet
Fires event cancelButtonPress to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
getButtons(): sap.m.Button[]

Gets content of aggregation buttons.

These buttons are added to the content area in ActionSheet control. When button is tapped, the ActionSheet is closed before the tap event listener is called.

Returns:
sap.m.Button[]
getCancelButtonText(): string

Gets current value of property cancelButtonText.

This is the text displayed in the cancelButton. Default value is "Cancel", and it's translated according to the current locale setting. This property will be ignored when running either in iPad or showCancelButton is set to false.

Returns:
stringValue of property cancelButtonText
getPlacement(): sap.m.PlacementType

Gets current value of property placement.

The ActionSheet behaves as an sap.m.Popover in iPad and this property is the information about on which side will the popover be placed at. Possible values are sap.m.PlacementType.Left, sap.m.PlacementType.Right, sap.m.PlacementType.Top, sap.m.PlacementType.Bottom, sap.m.PlacementType.Horizontal, sap.m.PlacementType.HorizontalPreferedLeft, sap.m.PlacementType.HorizontalPreferedRight, sap.m.PlacementType.Vertical, sap.m.PlacementType.VerticalPreferedTop, sap.m.PlacementType.VerticalPreferedBottom. The default value is sap.m.PlacementType.Bottom.

Default value is Bottom.

Returns:
sap.m.PlacementTypeValue of property placement
getPopupHiddenLabelId(): string
Gets the ID of the hidden label
Returns:
stringId of hidden text
getShowCancelButton(): boolean

Gets current value of property showCancelButton.

If this is set to true, there will be a cancel button shown below the action buttons. There won't be any cancel button shown in iPad regardless of this property. The default value is set to true.

Default value is true.

Returns:
booleanValue of property showCancelButton
getTitle(): string

Gets current value of property title.

Title will be shown in the header area in iPhone and every Android devices. This property will be ignored in tablets and desktop browser.

Returns:
stringValue of property title
indexOfButton(oButton): int
Checks for the provided sap.m.Button in the aggregation buttons. and returns its index if found or -1 otherwise.
Parameters:
sap.m.ButtonoButtonThe button whose index is looked for
Returns:
intThe index of the provided control in the aggregation if found, or -1 otherwise
insertButton(oButton, iIndex): sap.m.ActionSheet
Inserts a button into the aggregation buttons.
Parameters:
sap.m.ButtonoButtonthe button to insert; if empty, nothing is inserted
intiIndexthe 0-based index the button should be inserted at; for a negative value of iIndex, the button is inserted at position 0; for a value greater than the current size of the aggregation, the button is inserted at the last position
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
isOpen(): boolean
The method checks if the ActionSheet is open. It returns true when the ActionSheet is currently open (this includes opening and closing animations), otherwise it returns false.
Returns:
boolean
openBy(oControl): void
Calling this method will make the ActionSheet visible on the screen.
Parameters:
objectoControlThe ActionSheet behaves as an sap.m.Popover in iPad and the control parameter is the object to which the popover will be placed. It can be not only a UI5 control, but also an existing dom reference. The side of the placement depends on the placement property set in the popover. In other platforms, ActionSheet behaves as a standard dialog and this parameter is ignored because dialog is aligned to the screen.
removeAllButtons(): sap.m.Button[]

Removes all the controls from the aggregation buttons.

Additionally, it unregisters them from the hosting UIArea.

Returns:
sap.m.Button[]An array of the removed elements (might be empty)
removeButton(vButton): sap.m.Button
Removes a button from the aggregation buttons.
Parameters:
int|string|sap.m.ButtonvButtonThe button to remove or its index or id
Returns:
sap.m.ButtonThe removed button or null
setCancelButtonText(sCancelButtonText): sap.m.ActionSheet

Sets a new value for property cancelButtonText.

This is the text displayed in the cancelButton. Default value is "Cancel", and it's translated according to the current locale setting. This property will be ignored when running either in iPad or showCancelButton is set to false.

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

Parameters:
stringsCancelButtonTextNew value for property cancelButtonText
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
setPlacement(sPlacement): sap.m.ActionSheet

Sets a new value for property placement.

The ActionSheet behaves as an sap.m.Popover in iPad and this property is the information about on which side will the popover be placed at. Possible values are sap.m.PlacementType.Left, sap.m.PlacementType.Right, sap.m.PlacementType.Top, sap.m.PlacementType.Bottom, sap.m.PlacementType.Horizontal, sap.m.PlacementType.HorizontalPreferedLeft, sap.m.PlacementType.HorizontalPreferedRight, sap.m.PlacementType.Vertical, sap.m.PlacementType.VerticalPreferedTop, sap.m.PlacementType.VerticalPreferedBottom. The default value is sap.m.PlacementType.Bottom.

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

Default value is Bottom.

Parameters:
sap.m.PlacementTypesPlacementNew value for property placement
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
setShowCancelButton(bShowCancelButton): sap.m.ActionSheet

Sets a new value for property showCancelButton.

If this is set to true, there will be a cancel button shown below the action buttons. There won't be any cancel button shown in iPad regardless of this property. The default value is set to true.

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

Default value is true.

Parameters:
booleanbShowCancelButtonNew value for property showCancelButton
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
setTitle(sTitle): sap.m.ActionSheet

Sets a new value for property title.

Title will be shown in the header area in iPhone and every Android devices. This property will be ignored in tablets and desktop browser.

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

Parameters:
stringsTitleNew value for property title
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
attachCancelButtonTap(oData?, fnFunction, oListener?): sap.m.ActionSheet

Attaches event handler fnFunction to the cancelButtonTap event of this sap.m.ActionSheet.

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.ActionSheet itself.

This event is fired when the cancelButton is tapped. For iPad, this event is also fired when showCancelButton is set to true, and Popover is closed by tapping outside.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.ActionSheet itself
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
Deprecated API:
Since version 1.20.0. This event is deprecated, use the cancelButtonPress event instead.
detachCancelButtonTap(fnFunction, oListener): sap.m.ActionSheet

Detaches event handler fnFunction from the cancelButtonTap event of this sap.m.ActionSheet.

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

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
Deprecated API:
Since version 1.20.0. This event is deprecated, use the cancelButtonPress event instead.
fireCancelButtonTap(mParameters?): sap.m.ActionSheet
Fires event cancelButtonTap to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.ActionSheetReference to this in order to allow method chaining
Deprecated API:
Since version 1.20.0. This event is deprecated, use the cancelButtonPress event instead.