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

Flex利用Datagrid来设置全选和单选

发布时间:2020-12-15 04:34:30 所属栏目:百科 来源:网络整理
导读:1,效果预览图: 2,设置一个状态位,用于checkbox的选择的,从后台获取的对象集合ArrayCollection。假如其对象为Expert,有属性mainid,tname,major,depart!有两个方法设置状态位。 2.1 在后台给expert对象增加一个属性,譬如selected,类型为boolean,

1,效果预览图:

2,设置一个状态位,用于checkbox的选择的,从后台获取的对象集合ArrayCollection。假如其对象为Expert,有属性mainid,tname,major,depart!有两个方法设置状态位。

2.1 在后台给expert对象增加一个属性,譬如selected,类型为boolean,这样前台设置checkbox的列就可以用这个字段了

2.2 在前台处理

?protected function getallApp_result(event:ResultEvent):void
???{
????// TODO Auto-generated method stub
????allapplist = event.result as ArrayCollection;
????//初始化全部未选择
????for(var i:int=0;i<allapplist.length;i++)
????{
?????allapplist.getItemAt(i).selected=false;
????}
????
???}

这里就是在前台中加一个字段来设置

3,设置一个全局变量,来用于对标题栏上的checkbox做为状态位处理。

[Bindable]
???public var allSelectCheck:Boolean=false;
4,具体实现如下:

<mx:DataGrid id="appdg" styleName="DataGrid" width="766" height="90%" ???????? dataProvider="{allapplist}" ???????? horizontalScrollPolicy="on" headerStyleName="myHeaderStyles" color="#393939" x="74"> ??????<mx:columns> ???????<mx:DataGridColumn headerText="选择"? width="40" sortable="false"> ????????<mx:headerRenderer> ?????????<fx:Component> ??????????<mx:VBox horizontalAlign="center"> ???????????<mx:CheckBox selected="{outerDocument.allSelectCheck}" ?????????????? click="outerDocument.selectAll(this)" /> ??????????</mx:VBox> ?????????</fx:Component> ????????</mx:headerRenderer> ???????? ????????<mx:itemRenderer> ?????????<fx:Component> ??????????<mx:HBox horizontalAlign="center"> ???????????<mx:CheckBox selected="{data.selected}" ?????????????? click="data.selected =!data.selected"/> ??????????</mx:HBox> ?????????</fx:Component> ????????</mx:itemRenderer> ???????</mx:DataGridColumn> ???????<mx:DataGridColumn headerText="项目编号" dataField="appid" width="150"/> ???????<mx:DataGridColumn headerText="项目名称" dataField="appname" width="200"/> ???????<mx:DataGridColumn headerText="申请人" dataField="apppeople" width="80"/> ???????<mx:DataGridColumn headerText="申请类别" dataField="apptype" width="150"/> ??????</mx:columns>???? ?????</mx:DataGrid>

(编辑:李大同)

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

    推荐文章
      热点阅读