All docs
V19.1
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
The page you are viewing does not exist in version 21.2.
21.1
The page you are viewing does not exist in version 21.1.
20.2
The page you are viewing does not exist in version 20.2.
20.1
The page you are viewing does not exist in version 20.1.
19.2
19.1
18.2
18.1
17.2
A newer version of this page is available. Switch to the current version.

DevExtreme jQuery - Customize Item Appearance

For a minor customization of ActionSheet buttons, you can use the default item template. This template defines the appearance of a button depending on whether specific fields are present or absent from the button's data object. For example, the following code generates three buttons, the first is not customized, the second is disabled, the type of the third button is danger.

JavaScript
$(function() {
    $("#actionSheetContainer").dxActionSheet({
        dataSource: [
            { text: "Reply" },
            { text: "Reply All", disabled: true },
            { text: "Delete", type: 'danger' }
        ]
    });
});

Using the default item template is the easiest way to customize an item, but it lacks flexibility. Instead, you can define a custom template. For Angular, AngularJS and Knockout apps, DevExtreme provides a markup component called dxTemplate. The following code shows how you can use dxTemplate to define a template for the ActionSheet buttons.

Angular
HTML
TypeScript
CSS
<dx-action-sheet
    [dataSource]="actionSheetData"
    [visible]="isActionSheetVisible"
    itemTemplate="link">
    <div *dxTemplate="let item of 'link'">
        <div class="action-sheet-button">
            <a href="#">{{item.text}}</a>
        </div>
    </div>
</dx-action-sheet>
import { DxActionSheetModule } from "devextreme-angular";
// ...
export class AppComponent {
    actionSheetData = [
        { text: "Reply" },
        { text: "Reply All" },
        { text: "Forward" },
        { text: "Delete" }
    ];
    isActionSheetVisible: Boolean = true;
}
@NgModule({
    imports: [
        // ...
        DxActionSheetModule
    ],
    // ...
})
.action-sheet-button {
    margin: 5px;
    padding: 10px;
    border: 1px dotted #080;
    background-color: white;
}
AngularJS
HTML
JavaScript
CSS
<div ng-controller="DemoController">
    <div dx-action-sheet="{ 
        dataSource: actionSheetData,
        itemTemplate: 'link',
        bindingOptions: {
            visible: 'isActionSheetVisible'
        }
    }" dx-item-alias="item">
        <div data-options="dxTemplate: { name: 'link' }">
            <div class="action-sheet-button">
                <a href="#">{{item.text}}</a>
            </div>
        </div>
</div>
angular.module('DemoApp', ['dx'])
    .controller('DemoController', function ($scope) {
        $scope.actionSheetData = [
            { text: "Reply" },
            { text: "Reply All" },
            { text: "Forward" },
            { text: "Delete" }
        ];
        $scope.isActionSheetVisible = true;
    });
.action-sheet-button {
    margin: 5px;
    padding: 10px;
    border: 1px dotted #080;
    background-color: white;
}
NOTE
The dx-item-alias directive specifies the variable that is used to access the item object.
Knockout
HTML
JavaScript
CSS
<div data-bind="dxActionSheet: { 
    dataSource: actionSheetData,
    visible: isActionSheetVisible,
    itemTemplate: 'link' 
}">
    <div data-options="dxTemplate: { name: 'link' }">
        <div class="action-sheet-button">
            <a href="#" data-bind="text: text"></a>
        </div>
    </div>
</div>
var viewModel = {
    actionSheetData: [
        { text: "Reply" },
        { text: "Reply All" },
        { text: "Forward" },
        { text: "Delete" }
    ],
    isActionSheetVisible: ko.observable(false)
};

ko.applyBindings(viewModel);
.action-sheet-button {
    margin: 5px;
    padding: 10px;
    border: 1px dotted #080;
    background-color: white;
}

If you use jQuery alone, combine the HTML markup for items manually with jQuery DOM manipulation methods. To apply this markup, use the itemTemplate callback function as shown in the following code.

JavaScript
CSS
$(function() {
    $("#actionSheetContainer").dxActionSheet({
        dataSource: [
            { text: "Reply", icon: 'arrowleft' },
            { text: "Reply All", icon: 'arrowleft' },
            { text: "Forward", icon: 'arrowright' },
            { text: "Delete", icon: 'close' }
        ],
        itemTemplate: function (itemData, itemIndex, itemElement) {
            var linkContainer = $("<div class='action-sheet-button'>");
            linkContainer.append("<a href='#'>" + itemData.text + "</a>");
            itemElement.append(linkContainer);
        }
    });
});
.action-sheet-button {
    margin: 5px;
    padding: 10px;
    border: 1px dotted #080;
    background-color: white;
}

You can also customize an individual ActionSheet button. For this purpose, declare a template for this button as a script and pass its id to the template field.

HTML
JavaScript
<script id="individualTemplate" type="text/html">
    <!-- ... -->
</script>
var actionSheetData = [
    { text: "Reply", template: $('#individualTemplate') },
    { text: "Reply All" },
    // ...
];

In addition, you can use a 3rd-party template engine to customize widget appearance. For more information, see the 3rd-Party Template Engines article.

See Also