Show TOC

Complex Syntax for Calculated FieldsLocate this document in the navigation structure

Complex (or "extended") syntax can be used for calculated fields in declarative views, such as HTML and XML views.

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

<script id="sap-ui-bootstrap"
      ...
        data-sap-ui-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
    "/>