首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

flex tree和DataGrid合并使用如何做

2012-02-29 来源:读书人网 【读书人网(Reader8.cn):综合教育门户网站】
flex tree和DataGrid合并使用怎么做要求tree显示在DataGrid中。位置是左边,右边显示相应tree节点的一些数据

flex tree和DataGrid合并使用怎么做
要求tree显示在DataGrid中。位置是左边,右边显示相应tree节点的一些数据,和统计数据。

[解决办法]
使用高级表格,参考这个

XML code
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">     <mx:Script>          <![CDATA[            import mx.controls.DateField;            import mx.events.AdvancedDataGridEvent;            import mx.collections.Sort;            import mx.collections.SortField;            import mx.utils.ObjectUtil;               import mx.collections.ArrayCollection;              import mx.collections.Grouping;            import mx.collections.GroupingCollection;            import mx.collections.GroupingField;            import mx.controls.Alert;                         [Bindable]             public var dpFlat:ArrayCollection = new ArrayCollection([               {Name:"name", Region:"Southwest", Territory:"Northern California", Territory_Rep:"T.R. Smith", Actual:55498, Estimate:50000},               {Name:"name", Region:"Southwest", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:8000},               {Name:"name", Region:"Southwest", Territory:"Arizona", Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},              {Name:"name", Region:"Southwest", Territory:"Abc", Territory_Rep:"Dana Binn", Actual:29885, Estimate:20000},              {Name:"name", Region:"Southwest", Territory:"Central California",  Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},               {Name:"name", Region:"Southwest", Territory:"evada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},               {Name:"name", Region:"Southwest", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},              {Name:"name", Region:"Southwest", Territory:"Srthern California", Territory_Rep:"Bauren Ipsum", Actual:38805, Estimate:40000},                {Name:"name", Region:"Southwest", Territory:"Vrthern California", Territory_Rep:"Fauren Ipsum", Actual:38805, Estimate:40000},               {Name:"name", Region:"Southwest", Territory:"Southern California", Territory_Rep:"Jane Grove", Actual:44913, Estimate:9000}]);                  ]]>    </mx:Script>     <mx:GroupingCollection id="gc" source="{dpFlat}" >        <mx:Grouping >            <mx:GroupingField id="gf" name="Estimate" caseInsensitive="true" />        </mx:Grouping>    </mx:GroupingCollection>    <mx:AdvancedDataGrid id="myADG"  width="100%" height="100%"         dataProvider="{gc}"        initialize="{gc.refresh()}"        displayItemsExpanded="true"        creationComplete="{myADG.expandAll()}"         defaultLeafIcon="{null}"        folderOpenIcon="{null}"        folderClosedIcon="{null}">        <mx:groupedColumns>            <mx:AdvancedDataGridColumn dataField="Region"/>            <mx:AdvancedDataGridColumn dataField="Territory" />            <mx:AdvancedDataGridColumn dataField="Territory_Rep" headerText="Territory Rep" sortable="false"/>            <mx:AdvancedDataGridColumn dataField="Actual" visible="false" />            <mx:AdvancedDataGridColumn dataField="Estimate" sortable="false"/>        </mx:groupedColumns>    </mx:AdvancedDataGrid></mx:Application> 


[解决办法]
在父节点进行数据合计,利用SummaryField,参考这个

XML code
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">     <mx:Script>          <![CDATA[            import mx.controls.DateField;            import mx.events.AdvancedDataGridEvent;            import mx.collections.Sort;            import mx.collections.SortField;            import mx.utils.ObjectUtil;               import mx.collections.ArrayCollection;              import mx.collections.Grouping;            import mx.collections.GroupingCollection;            import mx.collections.GroupingField;            import mx.controls.Alert;                         [Bindable]             public var dpFlat:ArrayCollection = new ArrayCollection([               {Name:"name", Region:"Southwest", Territory:"Northern California", Territory_Rep:"T.R. Smith", Actual:55498, Estimate:50000},               {Name:"name", Region:"Southwest", Territory:"Southern California", Territory_Rep:"Alice Treu", Actual:44985, Estimate:8000},               {Name:"name", Region:"Southwest", Territory:"Arizona", Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},              {Name:"name", Region:"Southwest", Territory:"Abc", Territory_Rep:"Dana Binn", Actual:29885, Estimate:20000},              {Name:"name", Region:"Southwest", Territory:"Central California",  Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},               {Name:"name", Region:"Southwest", Territory:"evada", Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},               {Name:"name", Region:"Southwest", Territory:"Northern California", Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},              {Name:"name", Region:"Southwest", Territory:"Srthern California", Territory_Rep:"Bauren Ipsum", Actual:38805, Estimate:40000},                {Name:"name", Region:"Southwest", Territory:"Vrthern California", Territory_Rep:"Fauren Ipsum", Actual:38805, Estimate:40000},               {Name:"name", Region:"Southwest", Territory:"Southern California", Territory_Rep:"Jane Grove", Actual:44913, Estimate:9000}]);                  ]]>    </mx:Script>     <mx:AdvancedDataGrid id="myADG"          width="100%" height="100%"          initialize="gc.refresh();">                 <mx:dataProvider>             <mx:GroupingCollection id="gc" source="{dpFlat}">                 <mx:Grouping>                     <mx:GroupingField name="Region">                       <mx:summaries>                           <mx:SummaryRow summaryPlacement="group">                             <mx:fields>                                 <mx:SummaryField dataField="Actual"                                      label="Min Actual" operation="MIN"/>                                 <mx:SummaryField dataField="Actual"                                      label="Max Actual" operation="MAX"/>                                 <mx:SummaryField dataField="Actual"                                      label="Sum Actual" operation="SUM"/>                             </mx:fields>                           </mx:SummaryRow>                         </mx:summaries>                     </mx:GroupingField>                 </mx:Grouping>             </mx:GroupingCollection>         </mx:dataProvider>                          <mx:columns>             <mx:AdvancedDataGridColumn dataField="Region"/>             <mx:AdvancedDataGridColumn dataField="Territory_Rep"                 headerText="Territory Rep"/>             <mx:AdvancedDataGridColumn dataField="Actual"/>             <mx:AdvancedDataGridColumn dataField="Estimate"/>             <mx:AdvancedDataGridColumn dataField="Min Actual"/>             <mx:AdvancedDataGridColumn dataField="Max Actual"/>             <mx:AdvancedDataGridColumn dataField="Sum Actual"/>         </mx:columns>      </mx:AdvancedDataGrid> </mx:Application>