当前位置: 代码迷 >> Web前端 >> DataGrid双击行数据取得对象
  详细解决方案

DataGrid双击行数据取得对象

热度:152   发布时间:2012-08-22 09:50:34.0
DataGrid双击行数据获得对象
<?xml version="1.0" encoding="utf-8"?>
<!-- LabelExample.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/mx"
               viewSourceURL="srcview/index.html">
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>

    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.ListEvent;
            protected function dataGrid_itemDoubleClickHandler(event:ListEvent):void
            {
                Alert.show("[MyFlexHero.com] 你选中了:"+dataGrid.selectedItem["a"]+","+dataGrid.selectedItem["b"]+","+dataGrid.selectedItem["c"]);
            }



        ]]>
    </fx:Script>

   
    <fx:Declarations>
        <s:ArrayCollection id="MyFlexHero">
            <s:source>
                <fx:Array>
                    <fx:Object a="1" b="One.1" c="One.2" />
                    <fx:Object a="2" b="Two.1" c="Two.2" />
                    <fx:Object a="3" b="Three.1" c="Three.2" />
                    <fx:Object a="4" b="Four.1" c="Four.2" />
                    <fx:Object a="5" b="Five.1" c="Five.2" />
                    <fx:Object a="6" b="Six.1" c="Six.2" />
                    <fx:Object a="7" b="Seven.1" c="Seven.2" />
                    <fx:Object a="8" b="Eight.1" c="Eight.2" />
                    <fx:Object a="9" b="Nine.1" c="Nine.2" />
                    <fx:Object a="10" b="Ten.1" c="Ten.2" />
                    <fx:Object a="11" b="Eleven.1" c="Eleven.2" />
                    <fx:Object a="12" b="Twelve.1" c="Twelve.2" />
                    <fx:Object a="13" b="Thirteen.1" c="Thirteen.2" />
                </fx:Array>
            </s:source>
        </s:ArrayCollection>
    </fx:Declarations>
   
   
    <mx:DataGrid id="dataGrid"
                 dataProvider="{MyFlexHero}"
                 width="300" itemDoubleClick="dataGrid_itemDoubleClickHandler(event)" doubleClickEnabled="true">
        <mx:columns>
            <mx:DataGridColumn dataField="a"
                               headerText="Column 123:" />
            <mx:DataGridColumn dataField="b"
                               headerText="Column 123:" />
            <mx:DataGridColumn dataField="c"
                               headerText="Column 123" />
        </mx:columns>
    </mx:DataGrid>

   
</s:Application>
  相关解决方案