'dataRequested pass variable in XML
Just wondering how do I pass a this or other variables in dataRequested and dataReceived in XML events? Something like the below:
<Select items="{
path: '/Countries',
events: {
dataRequested: '.onCountriesRequested($source)',
dataReceived: '.onCountriesReceived($source)',
change: '.onCountriesChange'
}
}">
Solution 1:[1]
'this' is the scope of your controller on which your view.xml is attached.
You can directly control everything related to your Select UI element in the related file Detail.controller.js or App.controller.js.
Just add an event listener in your UI element such as:
change="onCountriesChange"
Then define the function "onCountriesChange" in the corresponding controller.js, for example:
onCountriesChange : function(oEvent) {console.log(this);}
Or you can simply bind 'this' to your event handler by attaching it at the end of your function, for example
this.oVariable1 = "Test";
oSelect.attachEvent('dataReceived', function (oEvent) {
//write your logic here using this.oVariable1 for example
}.bind(this));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
