tags:

views:

25

answers:

2

i have following xml

  <?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>

Above is bind with a datagrid as below

<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>

How can i show Email in textbox when user select any item in the grid?

A: 

You have to set editable="true" in the DataGrid. If you only want the "Email" column to be editable, you can do it like this:

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

And the function:

public function editCell(event:ListEvent):void {
  dg.editedItemPosition = {columnIndex:1, rowIndex:event.rowIndex};
}
Thomas
+1  A: 
<mx:TextInput text="{dg.selectedItem.Email}"/>
Amarghosh