Flex 使用ArrayCollection的FilterFunction进行数据过滤

<? xmlversion="1.0"encoding="utf-8" ?> < mx:Application xmlns:mx ="http://www.adobe.com/2006/mxml" layout ="absolute" fontFamily ="simsun" fontSize ="12" creationComplete ="hs.send()" > < mx:Script > <![CDATA[ importmx.collections.ArrayCollection; importmx.rpc.events.*; importmx.controls.Alert; privatefunctionhsFault(event:FaultEvent):void{ Alert.show(event.message.toString(),"Error"); } privatefunctionhsResult(event:ResultEvent):void{ mydata=event.result.NewDataSet.TableasArrayCollection; mydata.filterFunction=NameFilterChanged; mydata.refresh(); } publicfunctionNameFilterChanged(item:Object):Boolean{ varname:String=item.姓名; varsno:String=item.学号; varsex:String=item.性别; if(cmbSex.selectedItem.data!="全部") return(sno.indexOf(txtSNO.text,0)>=0)&&(name.indexOf(txtName.text,0)>=0)&&(cmbSex.selectedItem.data==sex); else return(sno.indexOf(txtSNO.text,0)>=0)&&(name.indexOf(txtName.text,0)>=0); } [Bindable] privatevarmydata:ArrayCollection; ]]> </ mx:Script > < mx:HTTPService id ="hs" useProxy ="false" url ="绿色通道名单.xml" fault ="hsFault(event)" showBusyCursor ="true" result ="hsResult(event)" /> < mx:DataGrid dataProvider ="{mydata}" right ="10" left ="9" top ="38" bottom ="20" > < mx:columns > < mx:DataGridColumn headerText ="姓名" dataField ="姓名" /> < mx:DataGridColumn headerText ="性别" dataField ="性别" /> < mx:DataGridColumn headerText ="学号" dataField ="学号" /> < mx:DataGridColumn headerText ="准考证号" dataField ="准考证号" /> < mx:DataGridColumn headerText ="生源地" dataField ="生源地" /> < mx:DataGridColumn headerText ="身份" dataField ="身份" /> < mx:DataGridColumn headerText ="户口" dataField ="户口" /> < mx:DataGridColumn headerText ="部门" dataField ="部门" /> < mx:DataGridColumn headerText ="原因" dataField ="原因" /> < mx:DataGridColumn headerText ="财务处是否办理" dataField ="财务处是否办理" /> </ mx:columns > </ mx:DataGrid > < mx:Label x ="186" y ="12" text ="姓名:" /> < mx:TextInput id ="txtName" x ="229" y ="10" change ="{mydata.refresh()}" width ="95" /> < mx:ComboBox x ="391" y ="10" width ="94" id ="cmbSex" labelField ="title" change ="mydata.refresh()" > < mx:dataProvider > < mx:Array > < mx:Object title ="全部" data ="全部" /> < mx:Object title ="男" data ="男" /> < mx:Object title ="女" data ="女" /> </ mx:Array > </ mx:dataProvider > </ mx:ComboBox > < mx:Label x ="348" y ="12" text ="性别:" /> < mx:TextInput x ="76" y ="10" width ="102" id ="txtSNO" change ="{mydata.refresh()}" /> < mx:Label x ="33" y ="12" text ="学号:" /> </ mx:Application >
Flex 使用ArrayCollection的FilterFunction进行数据过滤_第1张图片

你可能感兴趣的:(xml,Flex,Adobe)