I need to pass a control's ID to the formatter. Here is my control definition:
<Text id="controlId" text="{parts:[{path: 'details>/key1'},{path: 'details>/key2'}], formatter: '.userFormatter._formatField'}"/>
The formatter is defined in another file:
sap.ui.define(
function(){
"use strict";
return {
_formatField: function(sText1, sText2){
console.log("this ---> ",this);
return sText1 + " - " + sText2;
}
}
Formatter definition in the relevant controller:
sap.ui.define([
"My/Namespace/controller/BaseController",
"My/Namespace/common/userFieldsFormatter"
], function(BaseController, userFormatter) {
"use strict";
return BaseController.extend("My.Namespace.controller.Detail", {
userFormatter: userFormatter
});
In console I see the controller object (tried to implement THIS solution to the similar problem - doesn't work).