Hi Shameer,

  Please make those red colored changes. The code will work. I have tested
this. Let me know if it doesn't works

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
backgroundGradientAlphas="[1.0, 1.0]"
    backgroundGradientColors="[#FFFFFF, #FFFFFF]"
    preinitialize="init()">

    <mx:Script>
        <![CDATA[
            import vo.Country;
            import vo.Region;
            import mx.collections.ArrayCollection;
            [Bindable]
            private var region:Region;
            [Bindable]
            private var country:Country;
            [Bindable]
            private var acDg:ArrayCollection;

            [Bindable]
            private var ac:ArrayCollection = new ArrayCollection([
            {country:'US',state:'NY',
                            children:[{region:'Region 1', amount:'200'},
                                    {region:'Region 2', amount:'300'},
                                    {region:'Region 3', amount:'400'}]},
            {country:'US',state:'NY',
                            children:[{region:'Region 1', amount:'200'},
                                    {region:'Region 2', amount:'300'},
                                    {region:'Region 3', amount:'400'}]},
            {country:'US',state:'NY',
                            children:[{region:'Region 1', amount:'200'},
                                    {region:'Region 2', amount:'300'},
                                    {region:'Region 3', amount:'400'}]},
            {country:'US',state:'NY',
                            children:[{region:'Region 1', amount:'200'},
                                    {region:'Region 2', amount:'300'},
                                    {region:'Region 3', amount:'400'}]},
            {country:'US',state:'NY',
                            children:[{region:'Region 1', amount:'2000'},
                                    {region:'Region 2', amount:'3000'},
                                    {region:'Region 3', amount:'4000'}]}

            ]);

            private function init():void
            {
                var countryArray:Array = [];
                acDg = new ArrayCollection();
                for(var i:int=0;i<ac.length;i++)
                {
                    var obj1:Object = ac[i];
                    var obj2:Array = ac[i].children;
                    var regionArray:Array = [];

                    for(var j:int=0;j<obj2.length;j++)
                    {
                        var region:Region = new Region(obj2[j].region,
obj2[j].amount);
                        regionArray.push(region);
                    }

                    var country:Country = new Country(obj1.country,
obj1.state, regionArray);
                    countryArray.push(country);

                }
                acDg = new ArrayCollection(countryArray);


            }
        ]]>
    </mx:Script>

    <mx:AdvancedDataGrid id="advgrid" width="50%" height="50%"
        >
        <mx:dataProvider>
            <mx:HierarchicalData id="hr" source="{acDg}">
            <mx:childrenField>regionArray</mx:childrenField>
            </mx:HierarchicalData>
        </mx:dataProvider>
        <mx:columns>
            <mx:AdvancedDataGridColumn headerText="Country"
dataField="country"/>
            <mx:AdvancedDataGridColumn headerText="State"
dataField="state"/>
            <mx:AdvancedDataGridColumn headerText="Region"
dataField="region"/>
            <mx:AdvancedDataGridColumn headerText="Amount"
dataField="amount"/>
        </mx:columns>
    </mx:AdvancedDataGrid>
</mx:Application>
--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

Reply via email to