2013-02-03 87 views
0

基本上我想要做的是隻選擇一個單元格,並讓關於該單元格的信息顯示爲它下面的框中的標籤。Select Cell datagrid flash builder

enter image description here

這是我的時刻:

<s:DataGrid selectionMode="multipleCells" x="726" y="0" width="446" height="50" requestedRowCount="0" click="itemClickEvent(event)"> 
         <s:columns> 
          <s:ArrayList> 
           <s:GridColumn width="63" dataField="dataField1" headerText="見積條件"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField2" headerText="原価見積"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField3" headerText="見積作成"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField4" headerText="見積発行"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField5" headerText="受註失注"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField6" headerText="納品"></s:GridColumn> 
           <s:GridColumn width="63" dataField="dataField7" headerText="請求"></s:GridColumn> 
          </s:ArrayList> 
         </s:columns> 

         <s:ArrayList> 
          <fx:Object dataField1="2" dataField2="1" dataField3="2" dataField4="1" dataField5="4" dataField6="1" dataField7="1"></fx:Object> 
         </s:ArrayList> 
        </s:DataGrid> 

private function itemClickEvent(event:Event):void 
      { 
       currentState='information_dropdown' 
       Alert.show("Row : " +event.rowIndex + "Column : " +event.columnIndex) 



      } 

雖然代碼顯示一個警告框,我想下它顯示爲一個標籤來代替。我確實在rowIndex和columnIndex部分出現錯誤。

任何建議將是偉大的。

回答

0

不是聽點擊事件上的DataGrid的,聽GridEvent.GRID_CLICK:

<s:DataGrid selectionMode="multipleCells" x="726" y="0" width="446" height="50" requestedRowCount="0" gridClick="itemClickEvent(event)"> 

,並更改監聽參數類型到GridEvent:

private function itemClickEvent(event:GridEvent):void 
{ 
    ... 
} 

的rowIndex和columnIndex應該再給予正確的結果。