This article presents how to format numbers in order to make collections and forms more user-friendly.
Note: The following examples are based on the configuration of a collection but can also be applied to forms. |
Table column/form field requirements
Before formatting your collection or form field, make sure that your field is a number:
- it should either directly refer to a number attribute type, for example, a decimal:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-01-attribute-type.jpg)
- or the field expression should return a converted string field into a number:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-02-to-number.jpg)
Then make sure you choose the appropriate Default Value Datatype, for our example, Decimal:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-03-value-datatype.jpg)
Number formatting
To continue with our product price decimal sample: if you want the price to be displayed with a thousand separator, a decimal separator followed by 2 digits, you should fill the display format in your table column (or form field in the case of a form):
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-04-display-format.jpg)
Note: Refer to the Developer Guide for more information about display formats. |
Result for the end-user
The exact result for the end-user will depend on his Decimal and Thousand separators' user profile settings.
For example, if the user has defined these separators:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-05-user-settings.jpg)
He will get the following result for our Price configuration:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-05-result-end-user-collection.jpg)
But if the user has defined these separators:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-06-user-settings-2.jpg)
He will get the following result for the same configuration:
![](https://www.semarchy.com/wp-content/uploads/2019/03/format-numbers-in-collections-and-forms-07-result-end-user-2.jpg)
Now you have the main keys to format numbers in collections and forms!