[flexcoders] numeric formatters - a small gripe

2007-10-25 Thread Paul Andrews
OK, I can always get around this stuff by writing my own formatter or 
extending an existing one, but I naively expect the number and currency 
formatters (say precision 2), to format 0.23 as 0.23 rather than .23. 
Similarly I expect -0.23 to be formatted as -0.23 and not return -.23.

I know there's ways round this, but I find this formatting default odd. Even 
if it were popular in some quarters (is it?), I'd at least expect the 
classes supplied by Adobe to allow the choice of having the formatter 
generate that leading 0 or not.

Is it just me that finds this odd? Am I right to expect that zero in front 
of the decimal point?

Paul 



Re: [flexcoders] numeric formatters - a small gripe

2007-10-25 Thread Paul Andrews
In case anyone wonders this is my quick and 'easy' workaround (here in 
DataGridColumn labelFunction, using a currency formatter 'valueFormat')..

The currency formatter has the currency symbol deliberately suppressed.

// DataGrid Column labelFunction (using a currency formatter called 
'valueFormat').

private function formatXXX(item:Object, XXX:DataGridColumn):String{
 return (Math.abs(Number(item.XXX))= 
1.0)?valueFormat.format(item.XXX):Number(item.XXX).toFixed(2);
}

   mx:CurrencyFormatter
id=valueFormat
currencySymbol=
decimalSeparatorTo=.
precision=2
thousandsSeparatorTo=,/

Paul

- Original Message - 
From: Paul Andrews [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Friday, October 26, 2007 2:56 AM
Subject: [flexcoders] numeric formatters - a small gripe


 OK, I can always get around this stuff by writing my own formatter or
 extending an existing one, but I naively expect the number and currency
 formatters (say precision 2), to format 0.23 as 0.23 rather than 
 .23.
 Similarly I expect -0.23 to be formatted as -0.23 and not return 
 -.23.

 I know there's ways round this, but I find this formatting default odd. 
 Even
 if it were popular in some quarters (is it?), I'd at least expect the
 classes supplied by Adobe to allow the choice of having the formatter
 generate that leading 0 or not.

 Is it just me that finds this odd? Am I right to expect that zero in front
 of the decimal point?

 Paul



 --
 Flexcoders Mailing List
 FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
 Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
 Yahoo! Groups Links