Number formatting

Tags: #<Tag:0x00007f13683f1d08>

Hi,

I’m looking for an easy way to format numbers with symbols and I’m struggling with numbro.js
I’m dealing with a lot of numeric data, some are amounts (in various currencies) others are weights, lengths, percentages pixels, … meaning many different symbols or abbreviations.

What I basically want is to be able to decide:

  • the number of decimals
  • which “symbol” (not only currencies) to use
  • if the symbol is a prefix or suffix
  • if I want thousand separator
  • if I want to force the + sign

For currency amounts I can’t use “cultures” as we have to deal with multiple currencies and have them formatted correctly.
An example ?
My “culture” is fr-FR I want all amounts to be formatted accordingly.
1000 USD need to be: 1 000,00 $ NOT $1,000.00
1000 EUR need to be: 1 000,00 €

I don’t see how “culture” will help if I want a weight in kilos displayed as “4,525 KG” ? Or a diamond in carats “0,54 cts”

I don’t find any examples but the ones using “culture” and currency amounts.

Handsometable documentation refers to numbro.js doc but it’s not helping, numbro.js says
formatting is done via a literal object ... all available options can be found in the code directly.

I would appreciate having documentation a literal object description, with all options and their meaning, and examples to tell me how to use these objects in handsontable…

I hope someone has solutions and examples …

Thanks,

Hi @olivier

the best way to change symbol + number or / number + symbol combinations would be to create custom renderers. Here is an example http://jsfiddle.net/mhebqs8p/

If you’d like to sort different types of weights you can use a sortFunction. Here’s an article https://handsontable.com/blog/articles/easy-ways-to-sort-different-types-of-data-in-your-app that our collegue wrote abput the sortFunction (with an example).