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"/>
    

      


  • 相关阅读:
    Vue部署到相对目录和解决刷新404的问题
    JavaScript时间格式转换
    在Vue中使用Chart.Js
    进制转换和大数除法
    esp8266必备知识
    php 添加 freetype支持
    Linux系统时间同步问题
    busybox date 时间的加减
    kubesphere-wokespaces
    添加系统环境变量
  • 原文地址:https://www.cnblogs.com/sharpxiajun/p/2178341.html
Copyright © 2011-2022 走看看