Show TOC

Using Complex Syntax to Define a FormatterLocate this document in the navigation structure

A formatter can be defined either globally, for the entire application, or in your controller.

Define a formatter as follows:

  • Defining a formatter in controller.js:

    myFormatter: function(sName) {
            return sName.toUpperCase();
        },
        
    myGenderFormatter: function(sGender) {
            var sValue = "Mr.";
            if (sGender === "female") {
                sValue = "Mrs.";
            }
            return sValue;  
        }
    
  • Defining a global formatter in the SAPUI5 application:

    <script type="text/javascript">
        // define a global formatter function
        var my = {};
        my.globalFormatter = function(iDay,iMonth,iYear) {
              return iDay + "/" + iMonth + "/" + iYear;
        } 
              ...