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.
JavaScript
- $(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.
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) {
- 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.
HTML
JavaScript
- <script id="individualTemplate" type="text/html">
- <!-- ... -->
- </script>
- const actionSheetData = [
- { text: "Reply", template: $('#individualTemplate') },
- { text: "Reply All" },
- // ...
- ];
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.