当前位置: 首页 > news >正文

动态显示/隐藏 DataGrid 的列

在List中选中一个就会显示相应的 DataGrid 的列。

 

 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=">http://www.adobe.com/2006/mxml" layout="horizontal" horizontalAlign="left"
    creationComplete="initApp()">
<mx:Script><![CDATA[
  import mx.controls.dataGridClasses.DataGridColumn;
  //import mx.controls.DataGrid;
  import mx.collections.XMLListCollection;
 
  [Bindable]
private var _xlcCatalog:XMLListCollection;    //the dataProvider for the DG

//run by creationComplete
public function initApp():void
{
    _xlcCatalog = new XMLListCollection(xmlCatalog.product);      //wrap the XML product nodes in an XMLListCollection
    lstColumns.selectedItems = new Array(dgHideShow.columns[0]);  //set the column list dataProvider to the DataGridColumns
}//initApp

private function hideShowColumns():void  {
   var aColumns:Array = dgHideShow.columns;
   var aSelectedColumns:Array = lstColumns.selectedItems;
   var dgc:DataGridColumn;
   var sDataField:String;
   var sDataFieldCur:String;
   var bFound:Boolean
   for (var i:int=0;i<aColumns.length;i++)  {
     bFound = false
     dgc = aColumns[i];
     sDataField = dgc.dataField;
     for (var j:int=0;j<aSelectedColumns.length;j++)  {
       sDataFieldCur = aSelectedColumns[j].dataField;
       if (sDataFieldCur == sDataField)  {
         bFound = true;
         break;
       }
     }//for (var j:
     if (bFound) {
       dgc.visible = true;
     } 
     else  {
       dgc.visible = false;
     }    
   }// for (var i:
}//
]]></mx:Script>  
  <mx:VBox>
    <mx:Label text="Multi-Select" />
    <mx:Label text="Columns" />
    <mx:List id="lstColumns" dataProvider="{dgHideShow.columns}"
        labelField="dataField"
        allowMultipleSelection="true"
        click="hideShowColumns()"  />   
  </mx:VBox>

  <mx:DataGrid id="dgHideShow" dataProvider="{_xlcCatalog}" rowCount="6" >
    <mx:columns>
      <mx:Array>
        <mx:DataGridColumn headerText="Product" dataField="name" visible="true" />
        <mx:DataGridColumn headerText="Description" dataField="description" visible="false" />
        <mx:DataGridColumn headerText="Price" dataField="price" visible="false" />
        <mx:DataGridColumn headerText="Series" dataField="series" visible="false" />

<mx:DataGridColumn headerText="Tri-Band" dataField="triband" visible="false" />
        <mx:DataGridColumn headerText="Camera" dataField="camera" visible="false" />
       </mx:Array>
    </mx:columns>   
  </mx:DataGrid>

  <mx:XML id="xmlCatalog">
    <catalog>
      <product productId="1">
        <name>Nokia 6010</name>
        <description>Easy to use without sacrificing style, the Nokia 6010 phone offers functional voice communication supported by text messaging, multimedia messaging, mobile internet, games and more</description>
        <price>99.99</price>
        <image>assets/pic/Nokia_6010.gif</image>
        <series>6000</series>
        <triband>false</triband>
        <camera>false</camera>
        <video>false</video>
        <highlight1>MMS</highlight1>
      <highlight2>Large color display</highlight2>
      </product>
      <product productId="2">
        <name>Nokia 3100 Blue</name>
        <description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on™ gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
        <price>139</price>
        <image>assets/pic/Nokia_3100_blue.gif</image>
        <series>3000</series>
        <triband>true</triband>
        <camera>false</camera>
        <video>false</video>
        <highlight1>Glow-in-the-dark</highlight1>
      <highlight2>Flashing lights</highlight2>
      </product>
      <product productId="3">
        <name>Nokia 3100 Pink</name>
        <description>Light up the night with a glow-in-the-dark cover - when it's charged with light you can easily find your phone in the dark. When you get a call, the Nokia 3100 phone flashes in tune with your ringing tone. And when you snap on a Nokia Xpress-on™ gaming cover*, you'll get luminescent light effects in time to the gaming action.</description>
        <price>139</price>
        <image>assets/pic/Nokia_3100_pink.gif</image>
        <series>3000</series>
        <triband>true</triband>
        <camera>false</camera>
        <video>false</video>
        <highlight1>Glow-in-the-dark</highlight1>
      <highlight2>Flashing lights</highlight2>
      </product>
      <product productId="4">
        <name>Nokia 3120</name>
        <description>Designed for both business and pleasure, the elegant Nokia 3120 phone offers a pleasing mix of features. Enclosed within its chic, compact body, you will discover the benefits of tri-band compatibility, a color screen, MMS, XHTML browsing, cheerful screensavers, and much more.</description>
        <price>159.99</price>
        <image>assets/pic/Nokia_3120.gif</image>

<series>3000</series>
        <triband>true</triband>
        <camera>false</camera>
        <video>false</video>
        <highlight1>Multimedia messaging</highlight1>
      <highlight2>Animated screensavers</highlight2>
      </product>
      <product productId="5">
        <name>Nokia 3220</name>
        <description>The Nokia 3220 phone is a fresh new cut on some familiar ideas - animate your MMS messages with cute characters, see the music with lights that flash in time with your ringing tone, download wallpapers and screensavers with matching color schemes for the interface.</description>
        <price>159.99</price>
        <image>assets/pic/Nokia_3220.gif</image>
        <series>3000</series>
        <triband>false</triband>
        <camera>true</camera>
        <video>false</video>
        <highlight1>MIDI tones</highlight1>
      <highlight2>Cut-out covers</highlight2>
      </product>
    </catalog>
  </mx:XML>
</mx:Application>

 

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • Plugin with id 'com.github.dcendents.android-maven' not found
  • Flex构建WebService应用
  • Python 接口测试(五)
  • url中文乱码解决大全
  • warning: unable to bind to property '' on class '' (class is not an IEventDispatcher)
  • Nim游戏
  • Linux下ifort的安装记录
  • Eclipse代码提示功能
  • 关于表格的一些特性
  • 应用程序初始化(0xc0000135)失败
  • linux下制作u盘启动盘
  • 网站防止SQL注入
  • 运用TensorFlow处理简单的NLP问题
  • SQL Server数据库挂马的解决办法
  • 双向数据绑定与单向数据绑定
  • 07.Android之多媒体问题
  • FastReport在线报表设计器工作原理
  • Flannel解读
  • Java多线程(4):使用线程池执行定时任务
  • java中的hashCode
  • Netty+SpringBoot+FastDFS+Html5实现聊天App(六)
  • PHP的类修饰符与访问修饰符
  • RxJS 实现摩斯密码(Morse) 【内附脑图】
  • sessionStorage和localStorage
  • 大快搜索数据爬虫技术实例安装教学篇
  • 技术发展面试
  • 聊聊redis的数据结构的应用
  • 世界上最简单的无等待算法(getAndIncrement)
  • 数据仓库的几种建模方法
  • 吐槽Javascript系列二:数组中的splice和slice方法
  • 小程序01:wepy框架整合iview webapp UI
  • scrapy中间件源码分析及常用中间件大全
  • 数据库巡检项
  • ​虚拟化系列介绍(十)
  • %@ page import=%的用法
  • (20)目标检测算法之YOLOv5计算预选框、详解anchor计算
  • (2024最新)CentOS 7上在线安装MySQL 5.7|喂饭级教程
  • (4)事件处理——(2)在页面加载的时候执行任务(Performing tasks on page load)...
  • (Matlab)基于蝙蝠算法实现电力系统经济调度
  • (附表设计)不是我吹!超级全面的权限系统设计方案面世了
  • (附源码)springboot宠物医疗服务网站 毕业设计688413
  • (附源码)springboot高校宿舍交电费系统 毕业设计031552
  • (十五)Flask覆写wsgi_app函数实现自定义中间件
  • (算法)区间调度问题
  • (转)visual stdio 书签功能介绍
  • (转载)VS2010/MFC编程入门之三十四(菜单:VS2010菜单资源详解)
  • .class文件转换.java_从一个class文件深入理解Java字节码结构
  • .NET C# 使用 SetWindowsHookEx 监听鼠标或键盘消息以及此方法的坑
  • .NET连接数据库方式
  • .net实现客户区延伸至至非客户区
  • @RestController注解的使用
  • []FET-430SIM508 研究日志 11.3.31
  • []利用定点式具实现:文件读取,完成不同进制之间的
  • [AIGC] 解题神器:Python中常用的高级数据结构
  • [Algorithm][综合训练][体育课测验(二)][合唱队形][宵暗的妖怪]详细讲解