Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS Number Formatting. 3 digits after decimal

Tags:

extjs

Using ExtJS4.1, I have floating point coming as JSON response. How can I format the floating value as 3 digits after decimal points. Find below the example. Please help.

enter code here

Example:

{ 
header: 'Total', 
sortable: true, 
dataIndex: 'total', 
field: { xtype: 'numberfield' }, 
renderer: this.onRenderCell 
}

onRenderCell : function(value, metaData, record, rowIndex,colIndex, store, view){
   Ext.util.Format.numberRenderer(value,'0.000');
   return value;            
}
------------------------------------------------------------------------
like image 762
Sashikant Avatar asked Jan 15 '23 01:01

Sashikant


1 Answers

You can use the number(v, format) function, for example:

Ext.util.Format.number(1.23456, '0.000');

witch will return:

"1.235"

(The numberRenderer witch you've tried returns a function)

like image 107
CD.. Avatar answered Jan 23 '23 07:01

CD..