如何在选择网格的同时访问行中的数据,以便进一步在Adobe Flex(ActionScript)的下面的文本字段中使用它?

fnvucqvd  于 2022-09-21  发布在  Apache
关注(0)|答案(1)|浏览(185)

我已经创建了一个从XML文件获取数据的网格。我需要获取整个行值,并相应地在下面的文本字段中显示它们。我能够获得所选行的行索引,但无法获得整个行数据。我尝试使用事件目标和网格选择索引

兹附上该代码以供参考。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       width="1186" height="646" backgroundColor="#FFFFFF"

                       applicationComplete="srv.send()"

                       >
    <s:layout>
        <s:BasicLayout/>
    </s:layout>

    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            import mx.core.mx_internal;
            import mx.events.FlexEvent;
                [Bindable]
            public function initFunc():void
            {
                thisButton.addEventListener("click",clickFunction);
            }

          **public function dada(event:Event):void
            {
            Alert.show(myGrid.selectedIndex.toString()+" "+event.target.text);
            naam.text=event.target.text

            }**

            protected function button1_creationCompleteHandler(event:FlexEvent):void
            {
                // TODO Auto-generated method stub

            }

        ]]>

    </fx:Script>
    <fx:Declarations>
        <mx:HTTPService id="srv" url="file:///C:/Users/Chaitanya.Galande/Desktop/first.xml">
        </mx:HTTPService>
    </fx:Declarations>

    <mx:VBox x="111" y="0" width="981" height="636" backgroundColor="#9CD0E3"
             contentBackgroundColor="#F5F5F5">
        <mx:DataGrid id="myGrid" width="856" click="dada(event)" color="#1B7DA6"
                     dataProvider="{srv.lastResult.Contacts.Contact}" fontSize="16">

        </mx:DataGrid>

        <mx:TextInput id="naam" text="dabcd"/>
        <mx:TextInput text="ada" id="age"/>
        <mx:TextInput text="ada" id="hobby"/>
        <mx:TextInput text="adasdadas" id="phone"/>
        <s:Button id="thisButton" height="39" label="Refresh" color="#9F41B6"
                  creationComplete="button1_creationCompleteHandler(event)" fontFamily="Courier New"
                  fontSize="20" fontStyle="normal" textDecoration="none" click="clickFunction(event)"/>
        <mx:Image source="a.png" />
    </mx:VBox>
</s:WindowedApplication>
r3i60tvu

r3i60tvu1#

使用selectedItem,而不是我在使用as3制作动画时使用的seltedIndex

相关问题