Skip to Content

Formatter

Hi,

I am experimenting with formatter function.

view.xml:

Controller.xml

How can I write the formatter function to show the status based upon experience. For example, experience=2 then Error, experience =4 then success like that.

What is the syntax I have to include in view.xml to call formatter function and where should I place formatter.js in the below project structure:

Thanks and Regards,

Teja.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Apr 06, 2016 at 10:45 AM

    Hi Teja,

    Follow below 4 steps to use formatter -

    1. Add formatter file in folder structure-

    2. Use it in View

    3. Associate it in controller

    4. Write code for formatter function -

    PS: Here i have bound the enabled property of toggle button using formatter which enables/disables the button based on conditions.

    Let us know if you need more help.

    BR.


    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      1. Create the formatter.js file in objectnumber folder.

      2. Reference the same in MyObjectNumber.controller.js specifying the full path. ( "<path>/objectnumber/formatter")

      3. use in view as -

      enabled="{parts: [{path:'processObjectModel>IsReadOnly'}, {path:'processObjectModel>SizeRelevant'}] , formatter : '.formatter.<name_of_formatter_function>'}"

      If its still not clear, please paste view and controller code.