我知道这可能很容易,但我无法弄清楚。
我有一个列表控件,可以从 Mysql 检索多个数据。当用户点击列表上的数据时,数据网格将显示数据并显示产品图像。
我可以看到数据网格中显示的乘法数据,但我不知道如何获取显示的单个数据。我不确定我是否很好地解释了这个问题。请参阅下面的代码并感谢您的回复。
<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.....
最佳答案
尝试这样的事情:
<mx:Image source="{dataGrid.selectedItem.sourcelocation}" />
如果您有一个正在运行的示例和/或对构成列表的值对象的解释,那么更具体会更容易。我觉得你的做法很奇怪;看来您正在使用 DataGrid 来显示单个项目。那是对的吗? DataGrid 适合以类似表格的格式显示多个相似的项目;我不确定是否会将其用于单个项目。
关于php - 如何访问ArrayCollection数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3112929/