首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >作为Horizontallist的数据提供程序的Flex类型的ArrayCollection

作为Horizontallist的数据提供程序的Flex类型的ArrayCollection
EN

Stack Overflow用户
提问于 2010-03-08 15:21:50
回答 4查看 1.6K关注 0票数 0

我有一个对象的ArrayCollection。我将这个数组作为数据提供程序传递给水平列表,并使用自定义的itemRenderer。

在执行应用程序时,水平列表将显示

代码语言:javascript
复制
[object CustomClass][object CustomClass][object CustomClass][object CustomClass]

我尝试将项目呈现器中的每个对象转换为:

代码语言:javascript
复制
<mx:Label text="{(data as CustomClass).label1}"/>

但这行不通..。

谢谢你能提供的任何帮助。致以敬意,

BS_C3

编辑-2010年3月9日

让我们来看看更多的代码=)

代码语言:javascript
复制
<?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不是空的(我对条目上的click事件使用了一个警报,并且我确实检索了预期的数据)。

希望这对>_<有帮助

你好,BS_C3

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-03-15 13:21:20

我设法解决了我的问题。

当我移除itemrenderer的vbox的宽度属性时,所有数据都出现在horizontalList中。为什么?我不知道为什么,但它似乎是定位的数据在一个可见的范围以外的水平(嗯??)

问题是现在一切都正常了。对于最后的代码,您有:

HorizontalList:

代码语言:javascript
复制
<mx:HorizontalList id="hlist"
    dataProvider="{TrayData.instance.itemsCollection}" 
    columnCount="{TrayData.instance.hlistColumns}"
    rowCount="1"
    itemRenderer="components.TrayItem"
    horizontalScrollPolicy="off"
    horizontalCenter="0" verticalCenter="0"
    borderStyle="none"
    horizontalScrollPosition="{TrayData.instance.hsPosition}"
    />

ItemRenderer:

代码语言:javascript
复制
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" >

    <mx:HBox width="100%">
        <mx:Spacer width="100%"/>
        <mx:Button label="x"/>
    </mx:HBox>
    <mx:HBox width="100%">
        <mx:Spacer width="15%"/>
        <mx:VBox width="70%">
            <mx:Image id="thumbnail" horizontalAlign="center"/>
            <mx:Label width="100%" textAlign="center" text="Collection"/>
            <mx:HBox width="100%">
                <mx:VBox id="labelBox" width="100">
                    <mx:Label width="100" text="GIA"/>
                    <mx:Label width="100" text="Finger Size"/>
                    <mx:Label width="100" text="Carat"/>
                    <mx:Label width="100" text="Color"/>
                    <mx:Label width="100" text="Clarity"/>
                    <mx:Label width="100" text="Shop"/>
                    <mx:Label width="100" text="Resizing"/>
                    <mx:Label width="100" text="Price"/>
                </mx:VBox>
                <mx:VBox id="dataBox" width="100%" horizontalAlign="left">
                    <mx:Label text="{data.resizingCode + ' ' + data.charg_st}"/>
                    <mx:Label text="{data.fingerSize}"/>
                    <mx:Label text="{((new Number(data.carats))/100).toString()}"/>
                    <mx:Label text="{data.color}"/>
                    <mx:Label text="{data.clarity}"/>
                    <mx:Label text="{data.lgort_fp}"/>
                    <mx:Label text="{data.net_price_fp}"/>
                </mx:VBox>
            </mx:HBox>
            <mx:Button label="Order" enabled="{data.product_type == 'C'}" width="50%"/>
        </mx:VBox>
        <mx:Spacer width="15%"/>
    </mx:HBox>

</mx:VBox>

你好,BS_C3

票数 0
EN

Stack Overflow用户

发布于 2010-03-08 15:25:24

你试过吗

代码语言:javascript
复制
<mx:Label text="{data.label1}"/>

?(label1是对象的属性)

票数 0
EN

Stack Overflow用户

发布于 2010-03-08 15:27:50

使用列表中的labelField字段,请参阅这里

代码语言:javascript
复制
<mx:List dataProvider="{myDataProvider}" labelField="label1"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2402327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档