<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/27/using-a-checkbox-control-as-a-list-item-renderer-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:vo="*"
    layout="horizontal"
    verticalAlign="middle"
    backgroundColor="white"
    creationComplete="init();">
 
 <mx:Script>
  <![CDATA[
   import mx.events.CollectionEvent;
   import mx.utils.ObjectUtil;
   
   private function init():void {
    arrColl.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
   }
   
   private function arrColl_collectionChange(evt:CollectionEvent):void {
    try {
     var tArr:Array = arrColl.source.filter(selectedOnly);
     textArea.text = ObjectUtil.toString(tArr);
     lbl.text = tArr.length.toString() + " item(s) selected";
    } catch (err:Error) {
     // ignore.
    }
   }
   
   private function selectedOnly(item:ListItemValueObject, idx:uint, arr:Array):Boolean {
    return item.isSelected;
   }
  ]]>
 </mx:Script>
 
 <mx:Array id="arr">
  <vo:ListItemValueObject label="One" isSelected="true" />
  <vo:ListItemValueObject label="Two" isSelected="true" />
  <vo:ListItemValueObject label="Three" isSelected="true" />
  <vo:ListItemValueObject label="Four" isSelected="true" />
  <vo:ListItemValueObject label="Five" isSelected="false" />
  <vo:ListItemValueObject label="Six" isSelected="false" />
  <vo:ListItemValueObject label="Seven" isSelected="false" />
  <vo:ListItemValueObject label="Eight" isSelected="false" />
  <vo:ListItemValueObject label="Nine" isSelected="false" />
  <vo:ListItemValueObject label="Ten" isSelected="false" />
  <vo:ListItemValueObject label="Eleven" isSelected="false" />
  <vo:ListItemValueObject label="Twelve" isSelected="false" />
 </mx:Array>
 
 <mx:ArrayCollection id="arrColl"
      source="{arr}"
      collectionChange="arrColl_collectionChange(event);" />
 
 <mx:Panel id="panel"
     title="Items"
     status="{arrColl.length} total"
     styleName="opaquePanel">
  <mx:List id="list"
     dataProvider="{arrColl}"
     alternatingItemColors="[#EEEEEE, white]"
     width="150"
     rowCount="8">
   <mx:itemRenderer>
    <mx:Component>
     <mx:CheckBox selectedField="isSelected"
         change="onChange(event);">
      <mx:Script>
       <![CDATA[
        private function onChange(evt:Event):void {
         data.isSelected = !data.isSelected;
        }
       ]]>
      </mx:Script>
     </mx:CheckBox>
    </mx:Component>
   </mx:itemRenderer>
  </mx:List>
  <mx:ControlBar horizontalAlign="right">
   <mx:Label id="lbl" />
  </mx:ControlBar>
 </mx:Panel>
 
 <mx:TextArea id="textArea"
     verticalScrollPolicy="on"
     width="100%"
     height="{panel.height}" />
 
</mx:Application>

package
{
 public class ListItemValueObject
 {  
  [Bindable]
  public var label:String;
  
  [Bindable]
  public var isSelected:Boolean;
  
  public function ListItemValueObject() {
   super();
  }
 }
}

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical"
    verticalAlign="middle"
    backgroundColor="white">
 
 <mx:Script>
  <![CDATA[
   import mx.controls.dataGridClasses.DataGridColumn;
   
   private function toggleFilter():void {
    if (checkBox.selected) {
     arrColl.filterFunction = processFilter;
    } else {
     arrColl.filterFunction = null;
    }
    arrColl.refresh();
   }
   
   private function processFilter(item:Object):Boolean {
    return parseFloat(item.value) == 0;
   }
   
   private function value_labelFunc(item:Object, col:DataGridColumn):String {
    return item[col.dataField].toFixed(2);
   }
  ]]>
 </mx:Script>
 
 <mx:ArrayCollection id="arrColl">
  <mx:source>
   <mx:Array>
    <mx:Object name="ColdFusion" value="0.00" />
    <mx:Object name="Dreamweaver" value="0.12" />
    <mx:Object name="Fireworks" value="1.01" />
    <mx:Object name="Flash" value="0" />
    <mx:Object name="Flash Player" value="-0.00" />
    <mx:Object name="Flex" value="0.00" />
    <mx:Object name="Illustrator" value="2.92" />
    <mx:Object name="Lightroom" value="0.32" />
    <mx:Object name="Photoshop" value="0.06" />
   </mx:Array>
  </mx:source>
 </mx:ArrayCollection>
 
 <mx:Panel status="{arrColl.length}/{arrColl.source.length} item(s)">
  <mx:DataGrid id="dataGrid"
      dataProvider="{arrColl}"
      verticalScrollPolicy="on">
   <mx:columns>
    <mx:DataGridColumn dataField="name" />
    <mx:DataGridColumn dataField="value"
           labelFunction="value_labelFunc" />
   </mx:columns>
  </mx:DataGrid>
  <mx:ControlBar>
   <mx:CheckBox id="checkBox"
       label="Filter DataGrid"
       click="toggleFilter();" />
  </mx:ControlBar>
 </mx:Panel>
 
</mx:Application>

flex Datagrid checkbox的更多相关文章

  1. flex datagrid checkbox选中项目

    <?xml version="1.0" encoding="utf-8"?>  <mx:Application xmlns:fx=" ...

  2. Flex DataGrid可编辑对象实现Enter跳转

    来源:http://blog.sina.com.cn/s/blog_5ed17a730100vrja.html 在Flex DataGrid中实现点击Enter键可编辑对象跳转<?xml ver ...

  3. Flex DataGrid 添加控件

    哈喽,又和大家见面了.今天要写的东西是关于Flex DataGrid添加“编辑”或“删除”按钮. 下面是部分代码: <mx:DataGrid id="dgShow" x=&q ...

  4. easyui datagrid checkbox multiple columns have been done do

    lengku1987   2013-01-06 22:27:47   Sponsored Links   easyui datagrid checkbox multiple columns have ...

  5. Flex带Checkbox的Tree

    想把Flex自带的Tree控件改成带有checkbox的样式. 原本以为同DataGrid一样,添加一个ItemRenderer就行,结果发现行不通. 进Tree控件的源码看了一下,发现Tree在自己 ...

  6. jQuery EasyUI DataGrid Checkbox 数据设定与取值

    纯粹做个记录,以免日后忘记该怎么设定. 这一篇将会说明两种使用 jQuery EasyUI DataGrid 的 Checkbox 设定方式,以及在既有数据下将 checked 为 true 的该笔数 ...

  7. EasyUI datagrid checkbox数据设定与取值(转自http://blog.csdn.net/baronyang/article/dnetails/9323463,感谢分享,谢谢)

    这一篇将会说明两种使用 jQuery EasyUI DataGrid 的 Checkbox 设定方式,以及在既有数据下将 checked 为 true 的该笔数据列的 Checkbox 设定为 Che ...

  8. wpf DataGrid CheckBox列全选

    最近在wpf项目中遇到当DataGrid的header中的checkbox选中,让该列的checkbox全选问题,为了不让程序员写自己的一堆事件,现写了一个自己的自定义控件 在DataGrid的 &l ...

  9. EasyUI DataGrid Checkbox 多选 获取选中行中的内容

    <table id='grid' class='easyui-datagrid' style='width:950px;height:405px' url='Ajax-index.php?mod ...

随机推荐

  1. python安装 numpy&安装matplotlib& scipy

    numpy安装 下载地址:https://pypi.python.org/pypi/numpy(各取所需) copy安装目录.eg:鄙人的D:\python3.6.1\Scripts pip inst ...

  2. python中的BaseManager通信(二)文件二分

    提供服务部分(运行时在接收端未打开前不能关闭) #mainsec.py from multiprocessing import Process, Queue from multiprocessing. ...

  3. UVa 12661 - Funny Car Racing(Dijkstra)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. P2149 [SDOI2009]Elaxia的路线

    题目描述 最近,Elaxia和w**的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们 必须合理地安排两个人在一起的时间. Elaxia和w**每天都要奔波于宿舍和实验室之间,他们 希望在 ...

  5. Kali-linux使用NVIDIA计算机统一设备架构(CUDA)

    CUDA(Compute Unified Device Architecture)是一种由NVIDIA推出的通用并行计算架构,该架构使用GPU能够解决复杂的计算问题.它包含了CUDA指令集架构(ISA ...

  6. jquery mobile各类标签的refresh

    JQM里面当我们更新了某些页面标签(如: listview, radiobuttons, checkboxes, select menus)里的数据时,必须做refresh操作. 为什么必须做refr ...

  7. 一起玩树莓派3+使用Gitlab搭建专业Git服务

    http://bbs.eeworld.com.cn/thread-505256-1-1.html https://packages.gitlab.com/gitlab/raspberry-pi2 ht ...

  8. PHPStorm自定义主题配置

    1.下载喜欢的主题 官方下载地址:下载 2.将.icls主题文件放到PHPStorm的配置中 windows下主题位置:C:\Users\Administrator\.PhpStorm2017.3\c ...

  9. 修改linux系统的默认语言

    修改linux系统的默认语言: 1.全局修改:         所有用户都是同一种统一的语言设置          修改/etc/sysconfig/i18n文件          vi /etc/s ...

  10. volatile、static

    谈到 volatile.static 就必须说多线程. 1.一个线程在开始执行的时候,会开启一片自己的工作内存(自己线程私有),同时将主内存中的数据复制到自己 的工作内存,从此读写数据都是自己的工作内 ...