【发布时间】:2010-03-08 15:21:50
【问题描述】:
我有一个对象的 ArrayCollection。 我将此数组作为数据提供者传递给水平列表,并且我正在使用自定义 itemRenderer。
执行应用程序时,显示水平列表
[object CustomClass][object CustomClass][object CustomClass][object CustomClass]
我尝试将 itemrenderer 中的每个对象转换如下:
<mx:Label text="{(data as CustomClass).label1}"/>
但它不起作用......
感谢您提供的任何帮助。 问候,
BS_C3
编辑 - 2010 年 3 月 9 日
让我们再写一些代码 =)
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Component id="Item">
<mx:VBox width="180">
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="x"/>
</mx:HBox>
<mx:Image id="thumbnail"/>
<mx:Label width="100%" horizontalCenter="0" text="Collection"/>
<mx:HBox width="100%">
<mx:Label width="100" text="GIA"/>
<mx:Label text="{data.charg_st}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Finger Size"/>
<mx:Label text="xxxxxx"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Carat"/>
<mx:Label text="{data.carats}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Color"/>
<mx:Label text="{data.color}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Clarity"/>
<mx:Label text="{data.clarity}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Shop"/>
<mx:Label text="{data.lgort_fp}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Resizing"/>
<mx:Label text="{data.resizing}"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label width="100" text="Price Excl. VAT"/>
<mx:Label text="{data.net_price_fp}"/>
</mx:HBox>
</mx:VBox>
</mx:Component>
<mx:HorizontalList
dataProvider="{GlobalData.instance.tray}"
columnCount="4"
rowCount="1"
horizontalScrollPolicy="off"
itemRenderer="{Item}"
/>
</mx:Canvas>
仅供参考,horizonalList 数据提供者是对象的 ArrayCollection。
现在,水平列表正在显示空项目...具有正确的宽度... arraycollection 不为空(我正在对项目的单击事件使用警报,并且确实检索了预期的数据)。
希望这会有所帮助>_
问候, BS_C3
【问题讨论】:
-
你能添加更多代码或完整的测试用例吗?
-
没人有办法吗?我一直在尝试不同的解决方案,但它仍然不起作用。 itemrenderer 中的所有内容都显示为“BLANK”。就好像物品在那里,但有东西在隐藏它。我添加了一个 itemClick 事件来显示项目的数据,它确实显示...我还重新创建了 arraycollection 作为对象的arraycollection ...并且它不会改变水平列表的行为。还是得到一个空白项...我真的不明白>_
标签: apache-flex dataprovider arraycollection typed