2 Replies Latest reply on Aug 21, 2007 12:32 PM by Newsgroup_User

    number format mask

    Level 7
      Hi All,
      How can I format a number with a mask like #,###,###.##?
      I want to display the numbers in this way inside a grid using labelFunction.
      Thanks

      JFB


        • 1. Re: number format mask
          flexPro
          Check out NumberFormatter. It's easy to use and has loads of options. For what you're trying to accomplish, you'll want to set precision to 2 and useThousandsSeparator to true.
          • 2. Re: number format mask
            Level 7
            Thank you for u reply.
            I'm trying to do a generic function.
            public function formatNumber(item:Object, dc:DataGridColumn):String
            {
            if (item!=null){

            return usdFormatter.format(item.columnName);
            }else{
            return "0";
            }
            }

            <mx:CurrencyFormatter id="usdFormatter" precision="2"
            currencySymbol="$" decimalSeparatorFrom="."
            decimalSeparatorTo="." useNegativeSign="true"
            useThousandsSeparator="true" alignSymbol="right" />

            But I can't find the way to refer to the specific column that I'm using the
            function, I have to hard code the columnName.
            It's a way to pass the column name on the labelFunction?

            <mx:DataGridColumn headerText="per 1000" dataField="columnName"
            editable="false" labelFunction="formatNumber"/>
            Thanks

            JFB



            "flexPro" <webforumsuser@macromedia.com> wrote in message
            news:faf6g0$av4$1@forums.macromedia.com...
            > Check out NumberFormatter. It's easy to use and has loads of options.
            > For what you're trying to accomplish, you'll want to set precision to 2
            > and useThousandsSeparator to true.