根据输入key值设定Dropdownlist应该显示的name

<s:DropDownList id="dropDownList1"  dataProvider="{list}" labelField="name"/>

 

this.dropDownList1.selectedIndex = indexOf(S001,dropDownList1,"key");

/**
 * 取得指定下拉列表控件索引ID
 */
private function indexOf(searchId:String,obj:Object,key:String):int{
	var list:ArrayCollection = obj.dataProvider as ArrayCollection;
	if (list == null) {
		return -1;
	}
	//循环判断指定下拉表name所对应的下拉表ID
	for (var i:int = 0; i < list.length; ++i) {
		if (list.getItemAt(i)[key]==searchId){
			return i;
		}
	}
	return -1;
}

 

你可能感兴趣的:(list)