Skip to Content
avatar image
Former Member

SAPUI5 Formatter issue

Hi,

I want to implement formatter for displaying a value.

I am getting errors when I use this.

<ObjectNumber number="{

            path: 'Clabs',

            formatter: function(value){

                return value;

            }

}"/>

It works fine when I do this

I am getting errors when I use this.

<ObjectNumber number="{

            path: 'Clabs'

}"/>

I have set this data-sap-ui-xx-bindingSyntax="complex" in my index page too.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jan 14, 2015 at 12:40 PM

    You can't declare javascript functions in a XMLView.

    You should follow this guide to use Formatters:

    https://sapui5.hana.ondemand.com/sdk/#docs/guide/482df92c6e8b429c8fc9022179515194.html

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 13, 2015 at 09:57 PM

    your trying to write javascript into XML

    create a js formatter module outside of the XML

    my.Formatter = {

         formatClabs : function(sClabs){

            return <logic here>

       }

    }

    then call your formatter like

    <ObjectNumber number="{

                path: 'Clabs',

                formatter:'my.Formatter.formatClabs'

    }"/>

    look at the demokit examples for reference

    hth

    jsp

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 13, 2015 at 08:42 PM

    Hi Senthil,

    In your second case you do not need the formatter in that case do binding directly:

    <ObjectNumber number="{Clabs}"/>

    Hope this helps.

    Regards,

    Kedar

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Kedar, the formatter is not working. If I have some other statements in the formatter function, they are also not working.