PDA

View Full Version : How to Display 4 Decimals for Currency Cell in a Grid



funnyfox
1 Mar 2012, 10:38 AM
Hi
I have a field in a Grid which shows currency for example: $25.54.
I want to change the Decimal Precision to 4 (Like $25.5432) , How can I do that. Here is my code which I am using.



this.columns = [ {
text : 'Item Rate',
width : 100,
dataIndex : 'eRate',
renderer: 'usMoney',
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 100000
}

Adding currencyPrecison:4 or decimalPrecision:4 doesn't work for me. The cell still shows only 2 decimal places. Can anyone please help me with a solution for this problem.

Thanks
FunnyFox

tobiu
1 Mar 2012, 11:03 AM
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.Number-cfg-decimalPrecision

mark0978
1 Mar 2012, 12:15 PM
from util/Format.js



/**
* Format a number as US currency
* @param {Number/String} value The numeric value to format
* @return {String} The formatted currency string
*/
usMoney : function(v) {
return UtilFormat.currency(v, '$', 2);
},


maybe make your own formatter?



myMoney: function(v) {
return UtilFormat.currency(v, '$', 4);
}


Not sure what the context is when the renderer is called, if it is the column object or the grid itself, that would decide where you drop the method.

vietits
1 Mar 2012, 7:02 PM
Just use numbercolumn with format '$0.0000'.


this.columns = [ {
xtype: 'numbercolumn',
format: '$0.0000',
text : 'Item Rate',
width : 100,
dataIndex : 'eRate',
//renderer: 'usMoney',
editor: {
xtype: 'numberfield',
allowBlank: false,
minValue: 0,
maxValue: 100000
}

startchurch
23 Oct 2013, 12:59 PM
format: '$0.0000' is not a valid value, at least according to Sencha Architect.

alexandre.barbosa
20 Mar 2017, 2:01 AM
Hi All.

I'm starting with Sencha Architect and I have some doubts. I'm trying to apply a custom currency format in a column of a grid. I'm using renderer function to do this and everything is working, but if try to use Sencha Architect IDE I don't know how to do this, because the renderer function is not "visible" and if I try to add a basic function in the columns the IDE present a popup with an error "Uncaught TypeError: cfg.getAllowOnViewController is not a function".

Anyone knows the right way to do this in Sencha Architect?