UI Widgets ActionSheet

A widget consisting of a set of choices related to a certain task.

Included in: dx.phonejs.js, dx.all.js

The dxActionSheet widget is a sheet containing a set of buttons located one under the other. These buttons usually represent several choices relating to a single task.

This widget, like any other DevExtreme UI widget, can be created using one of three possible approaches: jQuery, Knockout or AngularJS. The following code demonstrates how to create the dxActionSheet widget using the Knockout approach.

HTML
<div data-bind="dxActionSheet: { dataSource: actionSheetData, visible: actionSheetVisible }"></div>

To control widget visibility, assign an observable Boolean variable to the visible configuration option.

JavaScript
var actionSheetVisible = ko.observable(false);

The following code sample illustrates how to display the action sheet.

JavaScript
actionSheetVisible(true);

Action sheet items are configured using an array of objects specified via the dataSource option. Each object represents an action sheet button. The following is a sample dxActionSheet data source.

JavaScript
var actionSheetData = [
    {text:"Reply", clickAction: replyClicked},
    {text:"ReplyAll", clickAction: replyAllClicked},
    {text:"Forward", clickAction: forwardClicked},
    {text:"Delete", clickAction: deleteClicked}
];

To display action sheet items, a default template is applied based on the following fields of the data source item objects. These fields are used as configuration options for the dxButton widget created for each action sheet item.

  • text
    Specifies text displayed on the button.
  • type
    Specifies the type of the button.
  • clickAction
    An action performed when the button is clicked.
  • disabled
    A Boolean value specifying whether the button is disabled or enabled.

To learn more about the fields used in the default item template, refer to the Default Item Template reference section of the widget.

You can introduce a custom template for action sheet items. For this purpose, add a div element with the data-options attribute set to dxTemplate. Provide the item name to the template. In this instance, the template will be applied automatically. See the Customize Widget Item Appearance topic to learn more about item templates.

See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxActionSheet widget is related to the Collection Containers category. So read an overview of the features that are common for collection container widgets in the Common Tasks topic of the Collection Containers article.
Show Example:
jQuery
<div class="button" data-bind="dxButton:{text:'Show action sheet', clickAction: showActionSheet}"></div>
<div id="actionSheetContainer" data-bind="dxActionSheet: { dataSource: actionSheetData, visible: actionSheetVisible }"></div>
actionSheetVisible = ko.observable(false);
actionSheetData = [
    {text:"Reply", clickAction: function(){ processClick("Reply")}},
    {text:"ReplyAll", clickAction: function(){ processClick("ReplyAll")}},
    {text:"Forward", clickAction: function(){ processClick("Forward")}},
    {text:"Delete", clickAction: function(){ processClick("Delete")}}
];
processClick = function(name){
    DevExpress.ui.notify( name + " clicked", "success", 3000 );
};
showActionSheet = function () {
    actionSheetVisible(true);
};
body{
    text-align:center;
}
.button{
    margin-top:25px;
}

Configuration

An object defining configuration options for the dxActionSheet widget.

Methods

This section describes the members used to manipulate the widget.

Events

This section describes events fired by this component.

Default Item Template

This section lists the data source fields that are used in a default template for action sheet items.

By default, a predefined item template is applied to display items of DevExtreme collection widgets. This template is based on certain fields of the data source provided for a widget. Below is the list of the fields that take part in a default item template for the dxActionSheet widget. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source. For details refer to the Customize Widget Item Appearance topic.