cancel
Showing results for 
Search instead for 
Did you mean: 

One formatter for multiple attributes

former_member724290
Participant
0 Kudos

ObjectStatus has three dynamic attributes. For each of them, I have to write my own formatting method with the same set of parameters.

1. Can I write one (universal) formatter for attributes?

2. How correct is my approach?

Accepted Solutions (0)

Answers (1)

Answers (1)

boghyon
Product and Topic Expert
Product and Topic Expert

This answer might help: Pass Static Value to Formatter Parameters in XML View

You can write one formatter and add value: 'TEXT', 'STATE', 'ICON', etc... to the "parts" in the property binding.

former_member724290
Participant
0 Kudos

Thanks Boghyon.

This will get rid of the three formatters, but will not reduce the code in the view.

Is it possible to use some kind of global formatter at the ObjectStatus level?

boghyon
Product and Topic Expert
Product and Topic Expert
0 Kudos

and_andrey You could define a property binding once (e.g. at the "text" property) and in the formatter, access the ObjectStatus instance and set its other properties accordingly. How to use "this" as the ObjectStatus instance is answered here: https://stackoverflow.com/a/54419469/5846045