<?xml version="1.0" encoding="utf-8"?>
<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" minWidth="955" minHeight="600">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
mx|AdvancedDataGrid {
font-size:18px;
}
</fx:Style>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<fx:Model id="prd">
<datas>
<prod>
<cgy>家电</cgy>
<name>冰箱</name>
<price>2330</price>
<desc>很好!</desc>
</prod>
<prod>
<cgy>家电</cgy>
<name>彩电</name>
<price>6533</price>
<desc>很好!很好!</desc>
</prod>
<prod>
<cgy>通讯</cgy>
<name>小灵通</name>
<price>4321</price>
<desc>不错!</desc>
</prod>
<prod>
<cgy>通讯</cgy>
<name>手机</name>
<price>311</price>
<desc>打不通!</desc>
</prod>
</datas>
</fx:Model>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.ItemClickEvent;
import mx.events.ListEvent;
private function doDoubleClick(event:ListEvent):void {
Alert.show(this.adg.selectedItem.name);
}
]]>
</fx:Script>
<mx:AdvancedDataGrid id="adg" width="600" height="300"
dataProvider="{prd.prod}" doubleClickEnabled="true" itemDoubleClick="doDoubleClick(event);" x="0" y="0">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="类型" dataField="cgy"/>
<mx:AdvancedDataGridColumn headerText="名称" dataField="name"/>
<mx:AdvancedDataGridColumn headerText="价格" dataField="price"/>
<mx:AdvancedDataGridColumn headerText="描述" dataField="desc"/>
</mx:columns>
</mx:AdvancedDataGrid>
<mx:AdvancedDataGrid id="adg2" creationComplete="myGroup.refresh()" width="600" height="300" x="650">
<mx:dataProvider>
<mx:GroupingCollection id="myGroup" source="{prd.prod}">
<mx:Grouping>
<mx:GroupingField name="cgy">
<mx:summaries>
<mx:SummaryRow summaryPlacement="last" >
<mx:fields>
<mx:SummaryField dataField="name" operation="COUNT" label="col_count"/>
<mx:SummaryField dataField="price" operation="SUM" label="col_price"/>
</mx:fields>
</mx:SummaryRow>
</mx:summaries>
</mx:GroupingField>
</mx:Grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="类型" dataField="cgy"/>
<mx:AdvancedDataGridColumn headerText="名称" dataField="name"/>
<mx:AdvancedDataGridColumn headerText="价格" dataField="price"/>
<mx:AdvancedDataGridColumn headerText="描述" dataField="desc"/>
<mx:AdvancedDataGridColumn headerText="数量" dataField="col_count"/>
<mx:AdvancedDataGridColumn headerText="总价" dataField="col_price"/>
</mx:columns>
</mx:AdvancedDataGrid>
</s:Application>
flex AdvancedDataGrid显示列表和分组显示列表
最新推荐文章于 2021-08-15 22:44:01 发布