----- Original Message ----- 
  From: jitendra jain 
  To: [email protected] 
  Sent: Thursday, November 22, 2007 10:22 AM
  Subject: [flexcoders] Number Formatter


  Hi guys

    I have to show percentage field in my datagrid. I used numberFormatter.
  But it gives me output i,e .99 instead of 0.99
  please help

  Thanks,
  JJain


>From an old post of mine..

Paul


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: <[email protected]>
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

Reply via email to