zoukankan      html  css  js  c++  java
  • Flex里DropDownList默认值记录

    Flex的s:DropDownList标签。 
    我们很多web的应用中,例如,修改操作,某些字段是用下拉框显示的,那么当你查询出来的值返回到页面时候,要根据所传来的值,显示相应的下拉的值,这个操作在flex有点特别,代码如下:

                   //下拉框的数据集
    public static var fileNameTypeDropDownList:ArrayCollection = new ArrayCollection([
    			{id:0,label:'Flag文件'},
    			{id:1,label:'固定文件名'},
    			{id:2,label:'正则表达式'}
    ]);
    
    //获取DropDownList选中元素的索引
    public static function getSelectedIndexByResult(list:ArrayCollection, key:String, result:Object):int{
    			var selectedIndex:int = 0;
    			try{
    				for(var i:int = 0; i<list.length; i++){
    					if(list[i][key] == result){
    						selectedIndex = i;
    						break;
    					}
    				}
    			}catch(e:Error){Alert.show(e.message);}
    			return selectedIndex;
    }
    
    var index:int = this.getSelectedIndexByResult(fileNameTypeDropDownList,'id',data['file_name'])
    
    //mxml使用
    <s:DropDownList id="userGroupComboBox" selectedIndex={index} requireSelection="true" dataProvider="{fileNameTypeDropDownList}" labelField="USER_GROUP_NAME"/>
    

      


  • 相关阅读:
    网络故障排除工具 | 快速定位网络故障
    Brocade博科光纤交换机zone配置
    博科Brocade 300光纤交换机配置zone教程
    游戏开发
    第8章 图
    第7章 二叉树
    第6章 树型结构
    第5章 递归
    第4章 字符串、数组和特殊矩阵
    第3章 顺序表的链式存储
  • 原文地址:https://www.cnblogs.com/sharpxiajun/p/2178341.html
Copyright © 2011-2022 走看看