I am having trouble sending data from the XML view to controller. It is easily achievable in JS views.
for example:-
In JS view:-
var btn = new sap.m.Button({
text:"click",
tap:function(){
callFunction(oEvent, "mycustomString");
}
});
How do I achieve the same using XML Views.
<Button text="click" tap="callFunction"/>
The above would only pass the event and not the "mycustomString". How to I do this?
You can do this by adding a custom data-parameter app:myData
in your view:
View
<mvc:View
...
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
...
>
<Button text="click" tap="callFunction" app:mydata="mycustomString"/>
...
Controller
callFunction: function(oControlEvent) {
console.log("data: " + oControlEvent.getSource().data("mydata"));
}
logs data: mycustomString