Percentage Formatter

Maybe this is a silly question. I am using the Data Formatter Percentage. I have defined as 2 decimals but in my mind is that I will get “93.20%” but when the second decimal is 0 I only get 93.2%. How can I force to have 2 decimals ??

Hi Juan,

Try by adding step="0.01" and .toFixed(2) formatter after the percentage formatter. The code will look like this in an input field.

step="0.01" dmx-on:blur="add_item_price.setValue(value.toNumber().toFixed(2))"

1 Like

I checked the different format methods and formatNumber and formatCurrency do return a fixed number of decimals while formatPercentage and formatSize return a max number of decimals (round to the number of decimals).

We should probably have the same behavior for all the formatters. My suggestion is then to have a fixed number of decimals and have a -1 value for not changing the decimals and show them all.

Let me know if this should change or if there are any issues against it.

I am good with this. But lets see what other users think.

This gets my vote.

I’m not in Wappler right now so cant check but will this not work?
YourValue.toNumber().round(2)