[英]How to access data from row in Grid while selecting it so that further it can be used in Text Field below in Adobe Flex (ActionScript)?
我創建了一個從 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>
使用 selectedItem 而不是 selectedIndex 我在動畫中使用的 as3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.