JavaScript/jQuery ActionSheet - Customize Item Appearance
For a minor customization of ActionSheet buttons, you can define specific fields in button data objects. 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.
- $(function() {
- $("#actionSheetContainer").dxActionSheet({
- dataSource: [
- { text: "Reply" },
- { text: "Reply All", disabled: true },
- { text: "Delete", type: 'danger' }
- ]
- });
- });
If you need a more flexible solution, define an itemTemplate.
- $(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) {
- const 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.
- <script id="individualTemplate" type="text/html">
- <!-- ... -->
- </script>
- const actionSheetData = [
- { text: "Reply", template: $('#individualTemplate') },
- { text: "Reply All" },
- // ...
- ];
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.