flex 中include应用例子以及高级DataGrid用法

下面红色部分为include引用外部as代码,蓝色部分为分组标签

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script> 
<![CDATA[  
import mx.collections.ArrayCollection; 
 include "HierarchicalDataForGroupedColumns.as";
]]>
</mx:Script>
 <mx:AdvancedDataGrid id="myADG"  width="100%" height="100%"  defaultLeafIcon="{null}">
  <mx:dataProvider> 
   <mx:HierarchicalData source="{dpHierarchy}"/> 
  </mx:dataProvider> 
  <mx:groupedColumns>  
  <mx:AdvancedDataGridColumn dataField="Region"/>  
  <mx:AdvancedDataGridColumn dataField="Territory"/>  
  <mx:AdvancedDataGridColumn dataField="Territory_Rep"    headerText="Territory Rep"/>  
  <mx:AdvancedDataGridColumnGroup dataField="Revenues">   
  <mx:AdvancedDataGridColumn dataField="Actual"/>   
  <mx:AdvancedDataGridColumn dataField="Estimate"/>
   <mx:AdvancedDataGridColumn dataField="Territory_Rep"/> 
    <mx:AdvancedDataGridColumn dataField="Territory"/>   
  </mx:AdvancedDataGridColumnGroup> 
  </mx:groupedColumns>
  </mx:AdvancedDataGrid></mx:Application>

下面代码为HierarchicalDataForGroupedColumns.as文件中的代码,注意此文件建立的是as文件而不是as类文件。

[Bindable]
public var dpHierarchy:ArrayCollection = new ArrayCollection([ {Region:"Southwest", Territory:"Arizona",  Territory_Rep:"Barbara Jennings",  Revenues:{Actual:38865, Estimate:40000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Arizona",  Territory_Rep:"Dana Binn",  Revenues:{Actual:29885, Estimate:30000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Central California",  Territory_Rep:"Joe Smith",  Revenues:{Actual:29134, Estimate:30000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Nevada",  Territory_Rep:"Bethany Pittman",  Revenues:{Actual:52888, Estimate:45000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Northern California",  Territory_Rep:"Lauren Ipsum",  Revenues:{Actual:38805, Estimate:40000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Northern California",  Territory_Rep:"T.R. Smith",  Revenues:{Actual:55498, Estimate:40000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Southern California",  Territory_Rep:"Alice Treu",  Revenues:{Actual:44985, Estimate:45000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}},
                 {Region:"Southwest", Territory:"Southern California",  Territory_Rep:"Jane Grove",  Revenues:{Actual:44913, Estimate:45000,Territory_Rep:"Barbara Jennings",Territory:"Arizona"}}]);

你可能感兴趣的:(datagrid,Flex,application,import,include,encoding)