cancel
Showing results for 
Search instead for 
Did you mean: 

Formatter

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185414
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi Ankit,

     Thanks  for the reply. Could you explain with my example. I though I am facing issues with the path I have given.

Thanks and Regards,

Teja.

ugurkaya
Active Participant
0 Kudos

Hey Teja,

Assuming your formatter and model path is correct, could you try this.

state="{path: 'empmodel>experience', formatter: 'objectnumber.Formatter.weightState' }"

former_member185414
Active Contributor
0 Kudos

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.

Answers (0)