2010-06-24 42 views
0

我知道這一個可能很容易,但我無法弄清楚。如何訪問ArrayCollection數據

我有一個列表控件,從Mysql檢索乘法數據。當用戶點擊列表中的數據時,數據網格將顯示數據並顯示產品圖像。

我可以看到我的dataGrid中顯示的乘法數據,但我不知道如何獲取顯示的單個數據。我不確定我是否很好地解釋了這個問題。請參閱下面的代碼並感謝您的回覆。

<s:List id="compList" 
width="250" 
height="350" 
creationComplete="compList_creationCompleteHandler(event)" 
itemRenderer="itemRenderer.compListItemRenderer" 
change="compList_changeHandler(event)" //when a user select a row, the datagrid will display the data. 
> 
<s:AsyncListView list="{compinfoResult.lastResult}"/> 

</s:List> 




<mx:DataGrid id="dataGrid" dataProvider="{compDetailinfoResult.lastResult}">  //The dataGrid display the data fine 
<mx:columns> 
<mx:DataGridColumn dataField="user" headerText="User"/> 
<mx:DataGridColumn dataField="brand" headerText="Brand"/> 
<mx:DataGridColumn dataField="compModel" headerText="Model"/> 
<mx:DataGridColumn dataField="picture" headerText="Product Picture"/> 
</mx:columns> 
</mx:DataGrid> 


<mx:Image source="??????" /> // I want to display productPicture here too but not sure what to add here..... 

回答

2

嘗試這樣:

<mx:Image source="{dataGrid.selectedItem.sourcelocation}" /> 

它會更容易更具體,如果你有一個正在運行的樣品和/或價值的物品,使你的名單的說明。你的方法對我來說似乎很奇怪;因爲看起來你正在使用DataGrid來顯示單個項目。那是對的嗎? DataGrids適用於在表格中顯示多個相似的項目,如格式;我不確定是否將它用於單個項目。

+0

感謝您的回覆。我想我沒有很好地解釋這個問題。我希望用戶單擊List控件數據並在DataGrid和圖像控件上顯示產品詳細信息。我確實有多個項目顯示在我的dataGrid中(請參閱上面的代碼)。您的代碼適用於單擊數據網格數據而不是List的用戶。我欣賞幫助。 – FlyingCat 2010-06-24 18:59:31

+0

沒關係。我想我現在明白了。我的問題並不清楚。 +1併爲您接受答案。 – FlyingCat 2010-06-24 19:00:58

+0

我希望我能幫上忙。我不明白這對多個項目意味着什麼。順便說一句,我的代碼沒有什麼可做的w /點擊DataGrid。點擊只是一種選擇DataGrid上的項目的方法[或List]感謝代表,但。 – JeffryHouser 2010-06-24 20:10:55