I am trying to re-use the formatter methods used in the xml view but from the controller. This is because I need to export to excel a ui.table and the class sap.ui.export.Spreadsheet get data is it is in the JSON Model and not as it looks like after the applying the formatter in the xml View.
sap.ui.define([
"../controller/BaseController",
"../model/models",
"../model/formatter"
],
function (BaseController, models, formatter) {
"use strict";
return BaseController.extend("ns.controller.Main", {
formatter: formatter,
_formattedUiTableData: function (sCode){
return formatter.getStatusText(sCode);
}
});
});
/////////////////at formatter.js /////////////////////////////////////////////
sap.ui.define(["../controller/BaseController"
], function () {
"use strict";
return {
serviceCoderDescription(sCode) {
const oResourceBundle = this.getOwnerComponent().getModel("i18n").getResourceBundle();
switch (sCode) {
case "A":
return oResourceBundle.getText("CodeA");
case "B":
return oResourceBundle.getText("CodeB");
default:
return sCode;
}
}
};
});