使用 XML 数据提供程序进行 Horizo​​ntallist 控制

发布于 2024-08-23 10:20:08 字数 2039 浏览 2 评论 0原文

我使用 Horizo​​ntalList 控件和 XML 文件作为数据提供程序。 这就是 XML 的外观:

<data>
    <zone name="Europe">
        .
        .
        .
    </zone>
    <zone name="Japan">
        <stores>
            .
            .
            .
        </stores>
        <collections>
            <collection id="id1">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id1Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
        </collections>
        <clarities>
            .
            .
            .
        </clarities>
    </zone> 
</data>

这就是我的控件的外观

<mx:XML id="data" source="assets/SOD_division.xml"/>

<mx:HorizontalList 
    dataProvider="{data.division.(@name=='Japan').collections}"
    columnCount="2"
    itemRenderer="Renderer"
    width="500"
    horizontalScrollPolicy="off"
    />

我尝试使用对象数组作为数据提供者。项目渲染器工作并且水平列表的行为符合我的预期。 但是,当我使用 xml 文件时,它是空的...

我不知道为什么它不起作用...-_-'...

感谢您提供的任何帮助 =)

问候, BS_C3

I'm using a HorizontalList control with an XML file as a data provider.
This is how the XML looks:

<data>
    <zone name="Europe">
        .
        .
        .
    </zone>
    <zone name="Japan">
        <stores>
            .
            .
            .
        </stores>
        <collections>
            <collection id="id1">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id1Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
            </collection>
            <collection id="id2Bis">
                <name>xxx</name>
                <model>xxx</model>
                <hierarchy>xxx</hierarchy>
                <thumbnail>assets/xxx.PNG</thumbnail>
        </collections>
        <clarities>
            .
            .
            .
        </clarities>
    </zone> 
</data>

And this is how my control looks

<mx:XML id="data" source="assets/SOD_division.xml"/>

<mx:HorizontalList 
    dataProvider="{data.division.(@name=='Japan').collections}"
    columnCount="2"
    itemRenderer="Renderer"
    width="500"
    horizontalScrollPolicy="off"
    />

I tried using an array of objects as a dataprovider. The item renderer works and the horizontallist behaves as I expect it to.
However, when I use an xml file, it's empty....

I don't know why it's not working... -_-' ...

Thanks for any help you can provide =)

Regards,
BS_C3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

始终不够爱げ你 2024-08-30 10:20:08

我注意到的第一件事是您的 DP 设置为:

dataProvider="{data.division.(@name=='Japan').collections}"

但这不是 XML 的结构。通过遵循您的 XML 示例,您的 DP 应该是:

dataProvider="{data.zone.(@name=='Japan').collections}"

现在,当您可能需要 XMLList 对象时,将返回一个 XML 对象,在这种情况下,您的 DP 应该是

dataProvider="{data.zone.(@name=='Japan').collections.collection}"

或者如果您不关心子项的本地名称:

dataProvider="{data.zone.(@name=='Japan').collections.children()}"

First thing I notice is that your DP is set as:

dataProvider="{data.division.(@name=='Japan').collections}"

But that's not the structure of your XML. By following your XML example your DP should be:

dataProvider="{data.zone.(@name=='Japan').collections}"

Now thats going to return an XML object when you probably want an XMLList object in which case your DP should be

dataProvider="{data.zone.(@name=='Japan').collections.collection}"

or if you don't care about the local name of the children:

dataProvider="{data.zone.(@name=='Japan').collections.children()}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文