动态显示/隐藏 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>
wpf datagrid 中按钮 动态显示 //若datagrid出现滚动条可能会出现问题需要加上下面俩句话。 //因为出滚动条时,为了显示加速,datagrid会加载一部分数据。另一些数据当滚动时在加载进去 这样初始化获取不到这些数据。 //在datagrid上添加上以下俩句话可以避免预加载数据,使数据全部加载出来 EnableColumnVirtualization="False" EnableRowVirtualization= 阅读详情

相关推荐

easyui datagrid 动态隐藏显示列

jquery easyui 扩展 datagrid 自定义动态隐藏显示列

datagrid中动态显示或隐藏某一列的方法(根据条件判断显示和隐藏)

在datagrid中,我们常常根据条件想展示或者隐藏某一列,即动态展示某列 1.在EasyUI中:  1)展示某列的方法:     $('#tt').datagrid('showColumn', 'XXX');  -----其中 XXX 是隐藏列的  field 属性值  2)隐藏某列的方法:     $('#tt').datagrid('hideColumn', 'XXX');  ----

醉过方知酒浓 3万+

华为海思IC笔试通关秘籍:物理/电路/工艺三大方向高频考点解析(附真题)

本文深度解析华为海思IC笔试中物理设计、电路设计和工艺制造三大方向的高频考点与备考策略。针对华为海思IC笔试机考的特点,提供了方向选择建议、核心知识梳理及真题实战技巧,帮助考生构建系统性复习框架,高效备战,提升通关成功率。

mars5的博客 1308

DataGrid中如何隐藏掉一列

使用DataGrid一般有2种办法1.AutoGenerateColumns=Ture2.AutoGenerateColumns=False 对于1,自动产生的列不在DataGrid.Columns集合里那就在DataGrid1_ItemCreated事件中加上这个if (e.Item.Cells.Count>1)   e.Item.Cells[1].Visible=false;对于2,不论a或b

raze的专栏 2431

半导体AMHS天车振动控制:从0.5G到超低振动的技术演进与工程实战

在先进晶圆厂中,自动化物料搬运系统(AMHS)的天车如同空中出租车,承担着晶圆盒(FOUP)在洁净室各工艺区间的转运任务。然而,当天车加减速、过弯或抓取时产生的机械振动通过轨道梁和建筑结构传递至光刻机等敏感设备,便可能直接威胁套刻精度与良率。传统被动减振方案依靠橡胶垫和弹簧,在0.5G指标时代曾行之有效,但在EUV光刻和先进制程面前已力不从心。主动振动控制技术通过传感器、控制器与作动器构成的闭环系统,在轨道吊点和机械手端实时输出反向力抵消振动,配合磁悬浮走行、轻量化结构及调度系统的路径优化,将振动从0.5G

weixin_29188043的博客 341

基因家族的鉴定-基于Windows系统上的HMMER

基因家族的鉴定-基于Windows系统上的HMMER。

liangjinghui123的博客 3241

WPF DataGrid控件隐藏栏显示

WPF DataGrid控件隐藏栏显示 一、先添加一个类BindingProxy: public class BindingProxy : Freezable { protected override Freezable CreateInstanceCore() => new BindingProxy(); public object Data { get => GetValue(DataProperty);

韬光养晦 1400

从硅到氮化镓:用Sentaurus TCAD仿真GaN HEMT功率器件,我踩过的那些坑

本文分享了使用Sentaurus TCAD仿真GaN HEMT功率器件的实战经验,详细解析了从硅基到氮化镓的技术转型中遇到的五大关键挑战:材料参数设置、极化效应建模、网格划分策略、陷阱模型校准以及仿真与实测数据匹配。通过具体案例和参数优化方法,帮助工程师避开常见陷阱,提升TCAD仿真精度与效率。

weixin_28726671的博客 379

动态显示/隐藏 DataGrid 的列

在List中选中一个就会显示相应的 DataGrid 的列 <?xmlversion="1.0"encoding="utf-8"?><mx:Applicationxmlns:mx="http://www.adobe.com/200...

aiqixiao2017的博客 131

2026华为OD机试(JavaScript)真题【E卷+A卷+B卷+C卷+D卷】目录+在线OJ

华为OD机试真题题库【E卷+A卷+B卷+C卷+D卷】目录,JavaScript实现。

MISAYAONE的博客 8万+

CasADi - 最优控制开源 Python/MATLAB 库

CasADi 是一款开源软件工具,用于数值优化,特别是最优控制(即涉及微分方程的优化)。该项目由 Joel Andersson 和 Joris Gillis 在鲁汶工程大学工程优化中心 (OPTEC) 在读博士生在 Moritz Diehl 的指导下发起。本文档旨在简要介绍 CasADi。

机器人控制与仿真应用 7930

flex datagrid动态显示/隐藏列

DataGridColumn中有一个visible属性.只要把那一列的属性设置为FLASE就行了。例如: &lt;mx:Script&gt;     &lt;![CDATA[         import mx.collections.ArrayCollection;      ... ...

中国flex开发者 585

HALCON机器视觉之结合LMI Gocator 5504进行手机折叠屏异物、折痕和胶体检测(基于C# + HALCON)

手机折叠屏是一种创新的屏幕技术,它允许屏幕在一定程度上进行折叠,从而在便携性和屏幕尺寸之间取得平衡。这种屏幕通常由多层材料组成,包括柔性显示层、保护层和胶水层等。本文将详细介绍如何使用C#编程语言,结合HALCON和LMI Gocator 5504来实现手机折叠屏的异物、折痕和胶体检测。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 9317

[解决]运行时动态的增加和删除Columns

叶凯:    昨晚装上VS.NET试了一下,运行时动态的显示/隐藏Columns不算难啊。    有两点也许容易忽视,一个是要把DataGrid1的AutoGenerateColumns设成"False",然后手动添加列,否则运行时DataGrid1.Columns.Count=0。    另一个是!IsPostBack中初始化CheckBoxList,或者其他类似控件,否则PostBack后又和

civ3的自习室 1270

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Easyui 右击DataGrid表头,可以动态显示、隐藏列

$('#dg').datagrid({ url: 'url', method: 'get', fitColumns: true, columns:[[ {field:'itemid',title:'Item ID',width:80} ]], onHeaderContextMen

qq_41533659的博客 830

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

jQuery动态显示和隐藏datagrid中的某一列的方法

动态显示和隐藏datagrid中的某一列的方法有很多,在接下来的文章中为大家介绍下jQuery是如何实现的  代码如下: $(function(){ $('#tt').datagrid({ title:'报表统计', width:1020, height:400, url:'', fitColumns:true, loadMsg:'正在获取,请稍侯...', singleS

unity3d,unity3d教程下载 637

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

easyui的datagrid显示或隐藏列

1.根据下拉框选择要显示的列    html:    javascript:        //因子被选中时     function factorOnSelect(nv, ov) {         if (data != "" && data != null && data != undefined) {             var all = ["SO2", "NO2", "

pyy的博客 3644

jquery easyui datagrid 动态隐藏列

jquery easyui datagrid 动态隐藏显示列

不畏惧被人讨厌而是勇往直前,不随波逐流而是激流勇进,这才是对人而言的自由。 1万+

【转】easyUI datagrid 动态控制列的隐藏和显示

方法一:{field:'pictureId',title:'是否有海报',width:70,align:"center", // v 当前字段值, r行对象, i为索引 formatter:function(v,r,i){ ...

620

easyui中datagrid动态显示和隐藏某一列

easyui中datagrid动态显示和隐藏某一列

qq_41309961的博客 2999

easyui datagrid表格头部鼠标右键进行列隐藏和展示

1、实现datagrid自定义初始化onHeaderContextMenu方法 新增文件jquery.easyui.datagrid.column.js [code="java"] // 动态改变列头. var cmenu; function $onHeaderContextMenu(e){ e.preventDefault(); if (!cmenu){ ...

iteye_5810的博客 1040
上一篇: 在 Tree 中查找节点。在对话框中输入要查找的节点的值
下一篇: 两个Flex的例子(附源码)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值