PDA

View Full Version : I HAVE PROBLEMS WITH Ext.util.Format.usMoney



rmorales
9 Mar 2011, 9:04 AM
Hi Everybody.

Mi name is Robert, i am software developer, i have been programing with Extjs.

I have problems whith "Ext.util.format.usMoney", this format shows decimal like: 127,000.00 but i dont need decimals, i want only the number like: 127,000.

can you help me?

fay
9 Mar 2011, 9:12 AM
How are you using it? Grid, NumberField, elsewhere? If a NumberField, take a look at AmountField in \examples\form\absform.js where you can specify decimalPrecision.

rmorales
9 Mar 2011, 9:15 AM
in a Colum Grid like:

{

dataIndex: 'valorunitario',
header: '<center><b>Valor Unitario</b></center>',
sortable: true,
renderer : Ext.util.Format.usMoney,
width: 130

}

fay
9 Mar 2011, 9:42 AM
You could try this (but it does seem a little convoluted):



// ...
renderer : function(value)
{
var s = Ext.util.Format.usMoney(value);
return s.substring(0, s.indexOf('.')); // Assumes decimal seperator is '.'
},
// ...

rmorales
9 Mar 2011, 11:45 AM
Fay, thanks a lot for your fast answer, this solved i would want.

I have other questions:

how can i use the same with a Numberfield?
could you show me a example?

fay
9 Mar 2011, 11:47 AM
a look at AmountField in \examples\form\absform.js where you can specify decimalPrecision


Have you tried AmountField?

rmorales
9 Mar 2011, 11:56 AM
i was looking the "absform" file, but it didn't show any about Numberfield, do you have the code?

fay
9 Mar 2011, 12:09 PM
Actually a NumberField has the allowDecimals (http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.NumberField&member=allowDecimals) config option that you should set to false.

absform.js is located in the \examples\form folder.

rmorales
9 Mar 2011, 1:03 PM
Yes, i know about allowDecimals in NumberField, but the problems is that i wanna show the number like: 127,000 but in NumberField its shows like: 127000.

brittongr
9 Mar 2011, 10:55 PM
Yes, i know about allowDecimals in NumberField, but the problems is that i wanna show the number like: 127,000 but in NumberField its shows like: 127000.

Take a look to my extension maybe it can help you... http://www.sencha.com/forum/showthread.php?125935-Number-field-with-currency-symbol-thousand-separator-with-international-support

rmorales
10 Mar 2011, 7:55 AM
Thanks a Lot Fay and Brittongr, i have solved my problem. Sencha are a very Strong Family.