Skip to main content

I’m trying to get a number field to display as currency, but with a custom number of places after the decimal. Essentially trying to trim the trailing zeroes for display purposes. Here’s my code but it doesn’t work. The field is defined with 8 decimals and it always displays with 8 decimals regardless of the actual value:


var field = argumentsu0]; var value = argumentsu1]; field.element.css({'text-align': 'right'}); if (value == null || value == 0) { skuid.ui.fieldRenderers.CURRENCYRfield.mode](field,value); } else { value = value.toString(); var valLen = value.length; var displayValue = (Number(value).toFixed(valLen-2)); skuid.ui.fieldRenderers.CURRENCYRfield.mode](field,displayValue); } 

This should do it.


var NUMBER_OF_DECIMAL_PLACES = 2; var field = arguments[0]; var value = arguments[1]; field.element.css({'text-align': 'right'}); if (value == null || value == 0) { skuid.ui.fieldRenderers.CURRENCY[field.mode](field,value); } else { field.metadata.scale = NUMBER_OF_DECIMAL_PLACES; skuid.ui.fieldRenderers.CURRENCY[field.mode](field,value); } 

Worked, thanks!