2010-02-02 103 views
0

我有以下XML檢索的FlexGrid項目

<?xml version="1.0" encoding="UTF-8" ?> 
    <Users> 
    <User> 
     <ID>SMSUser(63)</ID> 
     <Email>[email protected]</Email> 
    </User> 
    <User> 
     <ID>SMSUser(64)</ID> 
     <Email>[email protected]</Email> 
    </User> 
    </Users> 

以上是綁定一個DataGrid如下

<mx:Script> 
    <![CDATA[ 
     import mx.rpc.events.FaultEvent; 
     import mx.collections.ArrayCollection;  
     import mx.controls.Alert; 
     import mx.rpc.events.ResultEvent;  

     [Bindable] 
     private var xmlData:ArrayCollection; 

     private function resulthandler(e:ResultEvent):void 
     { 
      xmlData = e.result.Users.User;  
     } 
     private function faulthandler(e:FaultEvent):void 
     { 
      Alert.show("Error"); 
     } 


    ]]> 
</mx:Script> 


    <mx:HTTPService id="listData" result="resulthandler(event)" 
    fault="faulthandler(event)" resultFormat="object" 
    showBusyCursor="true" method="GET"> 
    </mx:HTTPService>   

    <mx:DataGrid id="dg" dataProvider="{xmlData}" > 
     <mx:columns> 
      <mx:DataGridColumn dataField="ID" headerText="ID" /> 
      <mx:DataGridColumn dataField="Email" headerText="Email" />  
     </mx:columns>     
    </mx:DataGrid> 

我如何可以顯示文本的電子郵件時,用戶選擇任何項目網格?

回答

1
<mx:TextInput text="{dg.selectedItem.Email}"/> 
0

您必須在DataGrid中設置editable="true"。如果你只是想在「電子郵件」一欄中可編輯,你可以做這樣的:

<mx:Datagrid id="dg" dataProvider="{xmlData}" itemClick="editCell(event)"> 

而且功能:

public function editCell(event:ListEvent):void { 
    dg.editedItemPosition = {columnIndex:1, rowIndex:event.rowIndex}; 
}