Show TOC

Extended Syntax for Calculated FieldsLocate this document in the navigation structure

Extended syntax can be used for calculated fields in declarative views, such as HTML and XML views.

Note

This extended syntax feature is marked as experimental. The feature is not fully compatible with existing syntax: If you use the feature, you have to escape curly brackets {}. Otherwise, the content in curly brackets is interpreted as extended calculated fields syntax.

To use the feature in your SAPUI5 application, set the configuration flag xx-bindingSyntax in the bootstrap as follows:

<script id="sap-ui-bootstrap"
      ...
        data-sap-ui-xx-bindingSyntax="complex">
    </script>

The following examples show how to use the feature:

  • You can mix text with calculated fields as follows:

    <Label text="Hello Mr. {
                             path:'/singleEntry/firstName', 
                             formatter: '.myFormatter'
                            }, 
                            {
                             /singleEntry/lastName
                            }
     " />
    Note

    Use translatable text in your application.

  • Use a syntax with leading quotation marks ("...") if you use MVC and your formatter or type is located in the controller. In the following example, the existing type or formatter function in the controller is used:

    <TextField value="{
                       path:'gender', 
                       formatter:'.myGenderFormatter'
                      } 
                      {firstName}, 
                      {lastName}
    "/>
  • If you have a global formatter function, use the following syntax:

    <TextField value="{
                  parts: [
                          {path:'birthday/day'},
                          {path:'birthday/month'},
                          {path:'birthday/year'}
                         ], 
                  formatter:'my.globalFormatter'
    }"/>
  • For a global type that is created with the specified format options, see the following example:

    <Label text="A type test: {
                               path:'/singleEntry/amount', 
                               type:'sap.ui.model.type.Float', 
                               formatOptions: { minFractionDigits: 1}
                              } EUR
    "/>