Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAPUI5 - XML view and Formatter

Dear all,

I'm going crazy! I have written a small app with a XML view.

In this app, the Formatter Method is not processed. Doing the same staff in a JS-view runs like hell.

Here's my code...



    "RESULT": [

        {   "WERKS": "1102",

            "QTY_PROZ": 4.564,

            "INFO": "Heidelberg


        {   "WERKS": "1701",

            "QTY_PROZ": 16.857,

            "INFO": "Bern"





sap.ui.controller("dummy.main", {

  onInit: function() {

  var oModel = new sap.ui.model.json.JSONModel();

  oModel.loadData("json/plants.json", false);




And my View:

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"

  controllerName="dummy.main" xmlns:html="">

    <Page showHeader="false" enableScrolling="false">

        <TileContainer id="container" tiles="{MAIN>/RESULT}" allowAdd="false" editable="false">

            <StandardTile number     = "{MAIN>QTY_PROZ}"

                          numberUnit = "%"

                          info       = "{MAIN>INFO}"

                          icon       = "sap-icon://building"

                          title      = "{ path: 'MAIN>WERKS', formatter: 'my.Formatter.getName() }"/>




the index.html




  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

  <script src="resources/sap-ui-core.js"







  var app = new sap.m.App({initialPage:"idmain1"});

  var page = sap.ui.view({id:"idmain1", viewName:"dummy.main", type:sap.ui.core.mvc.ViewType.XML});




  <script src="util/Formatter.js"></script>


  <body class="sapUiBody" role="application">

  <div id="content"></div>



Last but not least my Formatter.js which is in folder "util""my.Formatter");

my.Formatter = {

  getName : function (value) {

  if( value == "1102") return "DE";

  if( value == "1701") return "CH";

  return "xx";



As you can see, I'm trying to call a formatter for the title property of a StandardTile. the formatter method is in the file util/Formatter.js

But it is not processed by the runtime engine. The tile is displayed on the screen, but w/o the property "title".

I can call the method inside my Chrome debugger.manually, so from my point of view the code should know about the method.

Moving the getName directly into the controller is the same...

Any hint, why my formatter isn't called?

I really appriciate your support.

Former Member

Ah I see:

  1. You don't need to include a reference in your index.html to your formatter
  2. Since your formatter class is in a /util folder, you should declare it as "", and in your Controller add a"") reference at the top
  3. Same in your view; instead of referencing it as "my.Formatter.getName", use ""
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question