flex AdvancedDataGrid显示列表和分组显示列表

<?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>

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值