flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Amsellem <maurice.amsel...@systar.com>
Subject RE: Data type to convert and store a srting into decimal/float value
Date Wed, 26 Feb 2014 12:37:58 GMT
Here is a working sample code that shows what has been told:
- use of label function to format with 2 decimals,
- sorting works on the raw number value.


<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx">

    <s:layout>
        <s:VerticalLayout/>
    </s:layout>

    <mx:DataGrid id="dg" dataProvider="{coll}">
            <mx:columns>
                <mx:DataGridColumn dataField="label" />
                <mx:DataGridColumn dataField="amount" labelFunction="getTwoDecimalsLabel"
/>
            </mx:columns>
    </mx:DataGrid>

    <fx:Script><![CDATA[
        import mx.collections.ArrayCollection;

        [Bindable]
        private var coll: ArrayCollection = new ArrayCollection(

                [
                    { label: "abc", amount: 100} ,
                    { label: "def", amount: 10}   ,
                    { label: "ghi", amount: 50}
                ]
        )

        private function getTwoDecimalsLabel( item: Object , column: DataGridColumn): String
 {
              return Number(item[column.dataField]).toFixed(2);
        }
        ]]></fx:Script>

</s:Application>

-----Message d'origine-----
De : Maurice Amsellem [mailto:maurice.amsellem@systar.com] 
Envoyé : mercredi 26 février 2014 13:28
À : users@flex.apache.org
Objet : RE: Data type to convert and store a srting into decimal/float value

>Waiting for Om and Maurice if they have something in store for me.

You say it doesn't work for you, but it's difficult to help without seeing your code.

Can you provide some sample code that shows the issue  (typically , itemRenderer, conversion
code, and datagrid code) ?

Maurice 

-----Message d'origine-----
De : Ash1703 [mailto:ashish.yadav@firmwisegroup.com] 
Envoyé : mercredi 26 février 2014 13:24
À : users@flex.apache.org
Objet : RE: Data type to convert and store a srting into decimal/float value

@Kessler,

As you have mentioned it is with Spark control and i am using mx:controls in my code, if that
is the only option left then i will probably had to switch on to that.
Waiting for Om and Maurice if they have something in store for me..



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Data-type-to-convert-and-store-a-srting-into-decimal-float-value-tp5202p5216.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message