Custom
Overview
Custom action type can be used when none of the other actions fit the specific use case. It can have any parameters and should be handled by the card extension.Default behavior: none.
Examples
Custom action handled by extension:
{ "sap.card": { "extension": "./ShowMessageExtension", "header": { ... }, "content": { "data": { "request": { "url": "/products" } }, "item": { "title": "{Name}", "actionsStrip": [ { "text": "Add to Favorites", "actions": [ { "type": "Custom", "parameters": { "method": "addToFavorites", "name": "{Name}", "id": "{Id}" } } ] }, { "buttonType": "Transparent", "text": "Remove", "actions": [ { "type": "Custom", "parameters": { "method": "remove", "name": "{Name}", "id": "{Id}" } } ] } ] } } } }
Extension code:
ShowMessageExtension.prototype.init = function () { Extension.prototype.init.apply(this, arguments); this.attachAction(this._handleAction.bind(this)); }; ShowMessageExtension.prototype._handleAction = function (oEvent) { if (oEvent.getParameter("type") !== CardActionType.Custom) { return; } var oActionParams = oEvent.getParameter("parameters"); var pExecuteAction; if (oActionParams.method === "addToFavorites") { this._addItemToFavorites(oActionParams.id); } else if (oActionParams.method === "remove") { this._removeItem(oActionParams.id); } ... };Try it Out