2010-06-24 39 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