Formatting numbers via ExtJS or javascript

I use string.Format () to format some numbers on the server side.

double dd = 15453434.5345; Console.Write(String.Format("{0:N0}", dd)); Console.Read(); 

Above code is generated:

15453435

The number is rounded and we see a comma delimiter. How can I achieve this with ExtJS.

+4
source share
1 answer

Take a look at Ext.util.Format .

This class is a central place for formatting functions. It includes functions for formatting various types of data, such as text, dates, and numeric values.

Options include:

  • thousandSeparator
  • DecimalSeparator
  • currenyPrecision
  • currencySign
  • currencyAtEnd

Example:

 Ext.util.Format.thousandSeparator = ','; Ext.util.Format.decimalSeparator = ','; var num = (15453434.5345).toFixed(0); //And then: Ext.util.Format.number(num, '0,000.00'); //outputs 15,453,435 
+7
source

Source: https://habr.com/ru/post/1484595/


All Articles