加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex4 DropDownList组件的使用

发布时间:2020-12-15 05:00:19 所属栏目:百科 来源:网络整理
导读:在之前flex的项目中经常会用到类似comboBox组合框那样的组件,它就是DropDownList 简单的使用,如下所示: mx:Label text="按时间:" height="29"/ s:DropDownList id="selectType" horizontalCenter="31" top="20" selectedIndex="1" change="day_change(eve
在之前flex的项目中经常会用到类似comboBox组合框那样的组件,它就是DropDownList

简单的使用,如下所示:

 <mx:Label text="按时间:" height="29"/>
			  <s:DropDownList id="selectType"
							  horizontalCenter="31"
							  top="20" selectedIndex="1" change="day_change(event);" width="126">
				  <s:dataProvider>
					  <s:ArrayList source="[全部,按日,按月,按年,按时间范围]" />
				  </s:dataProvider>
			  </s:DropDownList>
		  </s:HGroup>

如果你需要从JAVA服务器后台获取该组件的dataprovider话,就需要手动赋值给其dataprovider属性,如下所示:
	/**
			 * 从服务器中获取服务器的集中器列表
			 * 修正 by xuzhongming
			 * */
			protected function fractionalQueryConcentUIDData_resultHandler(event:ResultEvent):void
			{

				//得到服务器返回的数据
				var resultConcentUID:String = event.result as String;
				var concentArr:Array = resultConcentUID.split(",");
				
				var i:int = 0;
				
				var concentAC:ArrayCollection =new ArrayCollection();
				
				for(var j:int = 0; j<concentArr.length;j++){
					concentAC.addItemAt({name:concentArr[j]},j);
				}
				
				//将集合赋给dropdownList对象
				selectConcentUID.dataProvider = concentAC;
				
				//重置其selectIndex,默认为第一个下标索引
				selectConcentUID.selectedIndex = 0 ;
		
			}

然后如果你想呈现该数据的话,如下所示:

	  <s:HGroup>
			  <mx:Label text="按集中器UID:" height="29"/>
			  <s:DropDownList id="selectConcentUID"
							  horizontalCenter="69"
						      labelField="name"
							  top="20" selectedIndex="1"  width="131">
			  </s:DropDownList>
		  </s:HGroup>

最后要在使用它的地方,使用它,如下所示:
			//集中器下拉框所选中的值
				concentUID = this.selectConcentUID.selectedItem.name;
				
				//查询所有日期的记录
			 if(selectType == 0){
					 if(concentUID =="全部"){
						 mark = 1;
					 }
					 else{
						 mark = 2;
					 }
				}
(完,待续...................)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读