Constructor
new module:caplin/element/formatter/DecimalFormatter()
Formats the value to the specified number of decimal places.
DecimalFormatter
is typically used in the XML Renderer Framework, but can be invoked programmatically
as in the following example which evaluates to '3.142':
If you are using this formatter in conjunction with the ThousandsFormatter in a localised application, please
ensure this DecimalFormatter comes before the ThousandsFomatter in the renderer xml, otherwise localised
decimal point characters will stop the DecimalFormatter from recognising the number.
caplin.element.formatter.DecimalFormatter.format(3.14159, {dp:3})
- Implements:
Methods
-
format(vValue, mAttributes) → {String}
-
Formats the value to the specified number of decimal places.
Parameters:
Name Type Description vValue
Variant the number (String or Number type). mAttributes
Map the map of attributes. Properties
Name Type Description dp
Number the number of decimal places to apply. Returns:
the number, formatted to the specified precision.- Type
- String