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

<?xmlversion="1.0"encoding="utf-8"?> <mx:Applicationxmlns: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:HTTPServiceid="hs"useProxy="false"url="绿色通道名单.xml"fault="hsFault(event)" showBusyCursor="true"result="hsResult(event)"/> <mx:DataGriddataProvider="{mydata}"right="10"left="9"top="38"bottom="20"> <mx:columns> <mx:DataGridColumnheaderText="姓名"dataField="姓名"/> <mx:DataGridColumnheaderText="性别"dataField="性别"/> <mx:DataGridColumnheaderText="学号"dataField="学号"/> <mx:DataGridColumnheaderText="准考证号"dataField="准考证号"/> <mx:DataGridColumnheaderText="生源地"dataField="生源地"/> <mx:DataGridColumnheaderText="身份"dataField="身份"/> <mx:DataGridColumnheaderText="户口"dataField="户口"/> <mx:DataGridColumnheaderText="部门"dataField="部门"/> <mx:DataGridColumnheaderText="原因"dataField="原因"/> <mx:DataGridColumnheaderText="财务处是否办理"dataField="财务处是否办理"/> </mx:columns> </mx:DataGrid> <mx:Labelx="186"y="12"text="姓名:"/> <mx:TextInputid="txtName"x="229"y="10"change="{mydata.refresh()}"width="95"/> <mx:ComboBoxx="391"y="10"width="94"id="cmbSex"labelField="title"change="mydata.refresh()"> <mx:dataProvider> <mx:Array> <mx:Objecttitle="全部"data="全部"/> <mx:Objecttitle="男"data="男"/> <mx:Objecttitle="女"data="女"/> </mx:Array> </mx:dataProvider> </mx:ComboBox> <mx:Labelx="348"y="12"text="性别:"/> <mx:TextInputx="76"y="10"width="102"id="txtSNO"change="{mydata.refresh()}"/> <mx:Labelx="33"y="12"text="学号:"/> </mx:Application>
阅读更多

flex ArrayCollection 的问题

09-27

rnrn rn 1rn laogaorn rn rnrnrn在xml中出现一个节点时 ArrayCollection 就返回rnTypeError: Error #1034: 强制转换类型失败:无法将 mx.utils::ObjectProxy@35c6701 转换为 mx.collections.ArrayCollection。rn at ArrayCollectionDemo/HandlerResult()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\ArrayCollectionDemo\src\ArrayCollectionDemo.mxml:15]rn at ArrayCollectionDemo/__DataService_result()[C:\Documents and Settings\Administrator\My Documents\Flex Builder 3\ArrayCollectionDemo\src\ArrayCollectionDemo.mxml:20]rn at flash.events::EventDispatcher/dispatchEventFunction()rn at flash.events::EventDispatcher/dispatchEvent()rn at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]rn at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:193]rn at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]rn at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]rn at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]rn at flash.events::EventDispatcher/dispatchEventFunction()rn at flash.events::EventDispatcher/dispatchEvent()rn at flash.net::URLLoader/onComplete()rn怎么解决呢?我用的是HttpService

没有更多推荐了,返回首页