<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"
    horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">
 
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
 
            [Bindable]
            private var dpFlat:ArrayCollection = new ArrayCollection([
              {Region:"Southwest", Territory:"Arizona", 
                  Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
              {Region:"Southwest", Territory:"Arizona", 
                  Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
              {Region:"Southwest", Territory:"Central California", 
                  Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
              {Region:"Southwest", Territory:"Nevada", 
                  Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
              {Region:"Southwest", Territory:"Northern California", 
                  Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
              {Region:"Southwest", Territory:"Northern California", 
                  Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
              {Region:"Southwest", Territory:"Southern California", 
                  Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
              {Region:"Southwest", Territory:"Southern California", 
                  Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},
              {Region:"NorthEast", Territory:"New York", 
                  Territory_Rep:"Jose Rodriguez", Actual:26992, Estimate:30000}, 
              {Region:"NorthEast", Territory:"New York", 
                  Territory_Rep:"lisa Sims", Actual:47885, Estimate:50000},  
              {Region:"NorthEast", Territory:"Massachusetts", 
                  Territory_Rep:"kelly o'connell", Actual:172911, Estimate:20000}, 
              {Region:"NorthEast", Territory:"Pennsylvania", 
                  Territory_Rep:"John Barnes", Actual:32105, Estimate:30000},
              {Region:"MidWest", Territory:"Illinois", 
                  Territory_Rep:"Seth Brown", Actual:42511, Estimate:40000}
            ]);
        ]]>
    </mx:Script>
    <mx:Panel title="AdvancedDataGrid Control" layout="vertical" color="0xffffff" borderAlpha="0.15" width="500"
         paddingTop="5" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center">
 
         <mx:AdvancedDataGrid id="myADG" width="100%" height="100%" color="0x323232" initialize="gc.refresh();">    <!--调用refresh()来更新视图-->    
            <mx:dataProvider>
                <mx:GroupingCollection id="gc" source="{dpFlat}">
                        <mx:Grouping>
<!--这个grouping的作用是指示生成的列表按照哪个字段进行排序,如果不设置,显示	效果则
                与datagrid一样,设置了N个,则显示出N级目录-->
                            <mx:GroupingField name="Region"/>
                            <mx:GroupingField name="Territory"/>
                        </mx:Grouping>
                </mx:GroupingCollection>
            </mx:dataProvider>        
 
            <mx:columns><!--这里是设定列标题-->
                <mx:AdvancedDataGridColumn dataField="Region"/>
                <mx:AdvancedDataGridColumn dataField="Territory"/>
                <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                    headerText="Territory Rep"/><!--指定了headerText则显示此内容,默认显示dataField的内容-->
                <mx:AdvancedDataGridColumn dataField="Actual"/>
                <mx:AdvancedDataGridColumn dataField="Estimate"/>
            </mx:columns>
       </mx:AdvancedDataGrid>
 
    </mx:Panel>
</mx:Application>