2014-01-05 349 views
0

我有一個時間獲得價值我的ID從與選擇的DataGrid行相關聯的XML項目赫克。獲取MX:AdvancedDataGrid選擇項目

enter image description here

這很奇怪,因爲我得到的selectedObject XML沒有問題,但由於某些原因,我不能得到的ID出來。

<mx:AdvancedDataGrid dataProvider='{pData}' sortExpertMode="true" id="myDataGrid" 
           width="100%" height="120" paddingLeft="0" dragEnabled="true" 
           selectionMode="multipleCells" allowMultipleSelection="true" 
           keyUp="onSelection(event)" mouseUp="onSelection(event)" 
           draggableColumns="false" > 

private function onSelection(event:Event):void 
     { 

      for each(var s:Series in myBarChart2.series){ 
       // initialize/empty dataTipItems of all series. 
       s.dataTipItems = []; 
      } 
      // For each of the selected cells to show multiple data tips at once  
      var n:int = event.currentTarget.selectedCells.length; 

      var selectedObject:XML = event.target.data; 
      var theId = selectedObject.playerStats.id.toString(); 

請幫幫我。

回答

0

我明白了。

// Important note::: The first element of XML is omitted when find this. 
      currentPlayer = event.target.data; 
      var theId = currentPlayer.id;