• Flex单击列显示例子


    <?xml version="1.0" encoding="utf-8"?>
    <mstr:MstrApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:mstr="http://web.microstrategy.com/visframe" xmlDataFile="GetcolumnData.xml" layout="absolute">
    <fx:Script>
    <![CDATA[
    import mx.controls.*;
    import mx.events.ListEvent;
    import mx.controls.dataGridClasses.*;


    [Bindable]//原始数据
    public var dataArr:Array = [{id:1,name:"苹果",count:100},
    {id:2,name:"西瓜",count:200},
    {id:3,name:"水蜜桃",count:50}]

    private function addItem():void{
    dataArr.push({id:uiId.value,name:uiName.text,count:uiCount.value})
    DataGrid2.dataProvider = dataArr
    }
    private function delItem():void{
    dataArr.pop();
    DataGrid2.dataProvider = dataArr
    }
    private function itemClick(e:ListEvent):void{
    var txt:String = "表头为: "+(e.target as DataGrid).columns[e.columnIndex].headerText+"\n"
    txt+="选中第 "+e.columnIndex+" 列\n"
    txt+="选中第 "+e.rowIndex+" 行\n"
    txt+="选中的行的数据为:\n"
    var dat:Object = (e.target as DataGrid).selectedItem
    for(var i:* in dat){
    txt+=" "+i+":"+dat[i]+"\n"
    }
    txt+="选中的单元可格的数据为 "+(e.target as DataGrid).selectedItem[(e.target as DataGrid).columns[e.columnIndex].dataField]+" \n"
    Alert.show(txt)
    }
    ]]>
    </fx:Script>

    <mx:DataGrid id="DataGrid2" itemClick="itemClick(event)" dataProvider="{dataArr}" width="430" y="10" x="10" height="208">
    <mx:columns>
    <mx:DataGridColumn headerText="序号" dataField="id"/>
    <mx:DataGridColumn headerText="名称" dataField="name"/>
    <mx:DataGridColumn headerText="数量" dataField="count" editorDataField="value"/>
    </mx:columns>
    </mx:DataGrid>
    <mx:NumericStepper id="uiId" x="10" y="241" width="150"/>
    <mx:TextInput id="uiName" x="10" y="288" width="150"/>
    <mx:NumericStepper id="uiCount" x="10" y="335" width="150"/>
    <mx:Label x="10" y="224" text="序号:"/>
    <mx:Label x="10" y="271" text="名称:"/>
    <mx:Label x="10" y="318" text="数量:"/>
    <mx:Button click="addItem()" x="10" y="368" label="添加" width="150"/>
    <mx:Button click="delItem()" x="290" y="368" label="删除最后一个" width="150"/>

    </mstr:MstrApplication>

    转载何处忘记了``

  • 相关阅读:
    MySQL InnoDB事务隔离级别脏读、可重复读、幻读
    数据结构与算法-Python/C
    Go语言 转至Nick老师博客
    短信验证功能、邮箱验证功能
    psutil模块
    简单邮件传输协议SMTP
    CSS3主要的几个样式笔记
    cURL的几个经典实例
    Socket进程通信机制
    对PDO的认识
  • 原文地址:https://www.cnblogs.com/wdw31210/p/2406238.html
Copyright © 2020-2023  润新知