<?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. Linux命令--网络管理

    write命令 Linux write命令用于传讯息给其他使用者. 使用权限:所有使用者. 语法 write user [ttyname] 参数说明: user : 预备传讯息的使用者帐号 ttyna ...

  2. Java的MD5加密和解密

    链接:http://www.cnblogs.com/android-blogs/p/5305598.html Java的MD5加密和解密 简单demo: import  java.security.* ...

  3. 中石油大学统考(大学英语B)押题笔记

    二. 词汇与结构 1. I will.意为“我会的”,固定搭配. 2. get tired of 是词组“对…厌烦了”的意思. 3. — ________ is your girl friend li ...

  4. 在 Deepin 中搭建 GitLab

    入职半个月了,一直在接受业务知识以及企业文化知识的培训,下周终于要开始上岗入手项目了.由于公司使用自己搭建的 GitLab 服务作为项目版本控制器,所以我决定学习一下 GitLab,由于这货跟 Git ...

  5. Java虚拟机13:Java类加载机制

    前言 我们知道我们写的程序经过编译后成为了.class文件,.class文件中描述了类的各种信息,最终都需要加载到虚拟机之后才能运行和使用.而虚拟机如何加载这些.class文件?.class文件的信息 ...

  6. Python version 3.6 required, which was not found in the registry错误解决

    问题: 安装pywin32出现Python version 3.6 required, which was not found in the registry错误解决 解决: 建立一个文件 regis ...

  7. 1053. [HAOI2007]反素数ant【DFS+结论】

    Description 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4.如果某个正整数x满足:g(x)>g(i) 0<i<x ,则称x为反质数.例如,整数 ...

  8. 随手练——HDU 1284 动态规划入门

    #include <iostream> #include <algorithm> #include <string.h> using namespace std; ...

  9. Linux学习总结(十五)文件查找 which whereis locate find

    which命令 用于查找并显示给定命令的绝对路径,环境变量PATH中保存了查找命令时需要遍历的目录.which指令会在环境变量$PATH设置的目录里查找符合条件的文件.也就是说,使用which命令,就 ...

  10. WEB安全 ACCESS 注入、盲注脚本

    http://www.xxx.cn/cp.asp?classid=3http://www.xxx.cn/cp.asp?classid=3 and //有拦截关键字http://www.xxx.cn/c ...