I am trying to call a the formatter. e.g. to transform a text to uppercase. I have two formatters, one is in the controller and one is globally in the utils folder.
i tried to call both, but none is called. Can someone help me please :(?
I have a global formatter in utils folder:
jQuery.sap.declare("my.app.util.Formatter");
my.app.util.Formatter = {
toUpperCase: function(sStr) {
return sStr.toUpperCase();
}
};
and one formatter in my controller (i do the require $.sap.require("my.app.util.Formatter");
as well):
myControllerToUpperCaseFormatter : function(sStr) {
console.log('I WILL DO NOTHING!');
return sStr.toUpperCase();
}
my XML:
<mvc:View controllerName="my.app.view.XXX"
xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:l="sap.ui.layout"
xmlns:f="sap.ui.layout.form" xmlns:c="sap.ui.core" xmlns="sap.m">
<Page class="sapUiFioriObjectPage" title="Test">
<content>
<Button text="{path: 'MyModel>/name', formatter: 'my.app.util.Formatter.toUpperCase'}"></Button>
<Button text="{path: 'MyModel>/name', formatter: '.myControllerToUpperCaseFormatter' }"></Button>
</content>
</Page>
Thanks for the help!