论坛首页 编程语言技术论坛

flex DataGrid和tree

浏览 2173 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2008-09-24  
这是通过一个例子来和大家一起学习flex中tree和DataGrid 用法
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	
	<mx:XML id="mydata">//这是我们用的数据 通过data的数据来判断显示
		<folder label="邮件" data="mail">
			<folder label="收件箱" data="inbox"/>
			<folder label="个人文件夹" data="person">
				<folder label="商务信件" data="business"/>
				<folder label="私人信件" data="private"/>
				<folder label="其他" data="other"/>
			</folder>
		<folder label="已删除" data="delete"/>
		</folder>
	</mx:XML>
	<mx:Script>
		<![CDATA[
			
			private function ListMailCatelog():void{//回调function
			var allArray:Array=mymail.toArray();
			var curArray:Array=allArray.filter(cateLogFilter);
			maildg.dataProvider=curArray;
			}
			private  function cateLogFilter(element:*,index:int,arr:Array):Boolean{
			return (element.catelog == mytree.selectedItem.@data);
			
			
			}
			
			
			
		]]>
	</mx:Script>
	<mx:ArrayCollection id="mymail">//右列显示的数据
		
		<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>business</mx:catelog>	
		</mx:Object>
			<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>business</mx:catelog>
		</mx:Object>
			<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>inbox</mx:catelog>
		</mx:Object>	
			<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>inbox</mx:catelog>
			
		</mx:Object>
		<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>private</mx:catelog>
			
		</mx:Object>	
			<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>private</mx:catelog>
			
		</mx:Object>
		<mx:Object>
			<mx:sender>nic</mx:sender>
			<mx:title>i love you</mx:title>
			<mx:catelog>other</mx:catelog>
			
		</mx:Object>
			<mx:Object>
			<mx:sender>
				nic
			</mx:sender>
			<mx:title>
				i love you
			</mx:title>
			<mx:catelog>other</mx:catelog>
			
		</mx:Object>
		<mx:Object>
			<mx:sender>
				nic
			</mx:sender>
			<mx:title>
				i love you
			</mx:title>
			<mx:catelog>delete</mx:catelog>
			
		</mx:Object>
			<mx:Object>
			<mx:sender>
				nic
			</mx:sender>
			<mx:title>
				i love you
			</mx:title>
			<mx:catelog>delete
			</mx:catelog>	
		</mx:Object>
			<mx:Object>
			<mx:sender>
				nic
			</mx:sender>
			<mx:title>
				i love you
			</mx:title>
			<mx:catelog>delete</mx:catelog>
			
		</mx:Object>
		
			<mx:Object>
			<mx:sender>
				nic
			</mx:sender>
			<mx:title>
				i love you
			</mx:title>
			<mx:catelog>delete
			</mx:catelog>
			
		</mx:Object>
	
	</mx:ArrayCollection>
	
	<mx:Panel x="0" y="10" width="530" height="369" layout="absolute">
		<mx:HDividedBox x="10" y="10" width="100%" height="100%">
			<mx:Tree id="mytree" width="30%" height="100%" dataProvider="{mydata}" labelField="@label" showRoot="true" change="ListMailCatelog();"></mx:Tree>
			<mx:DataGrid height="100%" id="maildg">
				<mx:columns>
					<mx:DataGridColumn headerText="收件人" dataField="sender"/>
					<mx:DataGridColumn headerText="邮件标" dataField="title"/>
					<mx:DataGridColumn headerText="日期" dataField="catelog"/>
				</mx:columns>
			</mx:DataGrid>
		</mx:HDividedBox>
	</mx:Panel>
	
</mx:Application>

 

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics