flex3 comboBox 变身可输入可过滤搜索下拉选项,实例代码片段
2012-01-06 15:16
531 查看
<fx:Script> <![CDATA[ ............... private var enterpriseInfoRO:RemoteObject=ServiceLocator.getInstance().getRemoteObject("enterpriseInfo_RO_ID") as RemoteObject; private var reportRO:RemoteObject=ServiceLocator.getInstance().getRemoteObject("reportRO") as RemoteObject; [Bindable] private var enterprise_info:Array=[]; [Bindable] public var inputEStr:String; private var checkBox:CheckBox; [Event(name="onDocumentLoadedError", type="flash.events.ErrorEvent")] ............ //加载企业信息 public function loadEnterpriseInfo():void { enterpriseInfoRO.getEnterprisesListByTID(cityInfo_CB_ID.selectedItem.value); enterpriseInfoRO.addEventListener(ResultEvent.RESULT, enterpriseInfo_Handle); } public function enterpriseInfo_Handle(e:ResultEvent):void { enterpriseInfoRO.removeEventListener(ResultEvent.RESULT, enterpriseInfo_Handle); if (e.result != null) { /**********返回列表*************/ var tempList:ArrayCollection=e.result as ArrayCollection; var arr:Array=tempList.toArray(); enterprise_info=[]; for (var a in arr) { enterprise_info.push({label: arr[a][1], value: arr[a][0]}); } enterpriseInfo_CB_ID.selectedIndex=0; //flag=true; loadReport(); } } //加载报表信息 public function loadReport():void { currentState='state1'; inputEStr=enterpriseInfo_CB_ID.text; if (enterpriseInfo_CB_ID.selectedItem != null) { reportRO.getReportInfo(enterpriseInfo_CB_ID.selectedItem.value, time_ID.getTime_flag(), time_ID.getDate()); reportRO.addEventListener(ResultEvent.RESULT, reportInfo_Handle); } } protected function search_keyUpHandler(event:KeyboardEvent):void { if(event.keyCode.toString()=='32'||event.keyCode.toString()=='13'||event.keyCode.toString()=='8'){ inputEStr=enterpriseInfo_CB_ID.text; enterpriseInfoRO.getEnterprisesListByValue(cityInfo_CB_ID.selectedItem.value,StringUtil.trim(inputEStr)); enterpriseInfoRO.addEventListener(ResultEvent.RESULT,_result_enterprise_bySearch); } } private function _result_enterprise_bySearch(e:ResultEvent):void{ enterpriseInfoRO.removeEventListener(ResultEvent.RESULT,_result_enterprise_bySearch); if(e.result != null){ /**********返回列表*************/ var tempList: ArrayCollection = e.result as ArrayCollection; var arr: Array = tempList.toArray(); var index:int=0; enterprise_info=[]; for(var a in arr) { enterprise_info.push({label:arr[a][0],value:int(arr[a][1])}); index++ } enterpriseInfo_CB_ID.text=inputEStr; enterpriseInfo_CB_ID.open(); } } public function reportInfo_Handle(e:ResultEvent):void { reportRO.removeEventListener(ResultEvent.RESULT, reportInfo_Handle); report_group_id.removeAllElements(); if (e.result != null) { /**********返回列表*************/ var tempList:ArrayCollection=e.result as ArrayCollection; var arr:Array=tempList.toArray(); for (var a in arr) { var vGroup:VGroup=new VGroup(); var image:Image=new Image(); image.source=(String(arr[a][3]) == "0" ? "assets/png/report.png" : "assets/png/report2.png"); image.name=String(arr[a][2]); image.useHandCursor="false"; image.buttonMode="true"; image.mouseChildren="false"; image.addEventListener(MouseEvent.CLICK, reportDetail); vGroup.addElement(image); var hGroup:HGroup=new HGroup(); var label:Label=new Label(); label.text="表" + arr[a][1]; var cb:CheckBox=new CheckBox(); cb.label="审核"; cb.selected=(String(arr[a][3]) == "0" ? false : true); cb.id=String(arr[a][0])+"##"+String(arr[a][2]); cb.addEventListener(Event.CHANGE,cb_change); hGroup.addElement(label); hGroup.addElement(cb); vGroup.addElement(hGroup); report_group_id.addElement(vGroup); } enterpriseInfo_CB_ID.text=inputEStr; } } ]]> </fx:Script> <s:BorderContainer width="100%" .............. <mx:FormItem label="企业:" indicatorGap="0"> <mx:ComboBox id="enterpriseInfo_CB_ID" dataProvider="{enterprise_info}" selectedIndex="0" editable="true" minWidth="100" change="loadReport()" keyUp="search_keyUpHandler(event)" width="200"/> </mx:FormItem> .............. </s:BorderContainer>
相关文章推荐
- 利用chosen.js插件实现下拉可搜索多选,控制选择个数,选项框复位,修改下拉选项的功能(附代码)
- easyui combobox开启搜索自动完成功能的实例代码
- 用jQuery实现可输入多选下拉组合框实例代码
- Angular搜索 过滤 批量删除 添加 表单验证功能集锦(实例代码)
- 纯js代码生成可搜索选择下拉列表的实例
- flex 3 combobox 实现关键字过滤搜索-代码示例
- jQuery实现下拉框功能实例代码
- jQuery 过滤not()与filter()实例代码
- easyui中如何设置下拉列表框combobox只能选择,列表框内不能输入
- .NET+JS对用户输入内容进行字数提示功能的实例代码
- php使用正则过滤js脚本代码实例
- javascript级联下拉列表实例代码(自写)
- C#中如何使ComboBox不能输入,只能从下拉列表中选择
- Struts2的输入校验实例代码
- 实现类似google搜索效果,文本框输入智能提示,没有用ajax控件和第三方控件,完全手写代码
- vueJs实现DOM加载完之后自动下拉到底部的实例代码
- 【代码笔记】iOS-下拉选项cell
- 【WPF】获取下拉列表(ComboBox)的选项(ComboBoxItem)的内容
- JavaScript输入邮箱自动提示实例代码
- bootstrap实现多个下拉框同时搜索的实例