首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flex绑定列表selectedItem

Flex绑定列表selectedItem
EN

Stack Overflow用户
提问于 2012-08-26 20:16:46
回答 1查看 475关注 0票数 0

我是flex的新手,正在尝试组合两个列表选择的数据(参见下面的代码):

代码语言:javascript
复制
<s:Label x="538" y="130" text="Industry of Interest:"/>
        <s:List id="reIndustry" x="538" y="150" width="165" height="122" dataProvider="{recruitIndustries}" labelField="industry"></s:List>
        <s:Label x="723" y="130" text="Qualifications:"/>
        <s:List id="reQualifications" x="723" y="150" width="165" height="122" selectedItem="reIndustry.selectedItem.qualification" labelField="qualification"></s:List>

我想要完成的是,当您从"reIndustry“中选择数据时,所选项目的更多数据将显示在"reQualifications”列表中。

以下是我的数据:

代码语言:javascript
复制
 <s:ArrayList id="recruitIndustries">
        <fx:Object industry="Admin/PA/Secretary" qualification="Other"/>
        <fx:Object industry="Automotive" qualification="Painter"/>
        <fx:Object industry="Building/Construct/Mine"/>
        <fx:Object industry="Engineering"/>
        <fx:Object industry="Finance/Accounting"/>
        <fx:Object industry="FMCG"/>
        <fx:Object industry="General Employment"/>
        <fx:Object industry="Health and Skincare"/>
        <fx:Object industry="Insurance"/>
        <fx:Object industry="International"/>
        <fx:Object industry="IT/Computer"/>
        <fx:Object industry="Legal"/>
        <fx:Object industry="Logistics"/>
        <fx:Object industry="Management"/>
        <fx:Object industry="Manufacturing"/>
        <fx:Object industry="Medical"/>
        <fx:Object industry="Part Time/ Temps"/>
        <fx:Object industry="Professions"/>
        <fx:Object industry="Retail"/>
        <fx:Object industry="Sales and Marketing"/>
        <fx:Object industry="Tourism/Hospitality"/>
    </s:ArrayList>

如果可能,如何在第二个列表"reQualifications“中添加更多要显示的值。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-27 13:32:24

@RIAstar问题是正确的。

你可以通过下面的代码来实现:

代码语言:javascript
复制
<fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;

            import spark.events.IndexChangeEvent;

            [Bindable]
            private var moreDataProvider:ArrayCollection = new ArrayCollection();
            private function itemClickHandler(event:IndexChangeEvent):void
            {
                moreDataProvider.removeAll();
                if(Object(reIndustry.selectedItem).hasOwnProperty('qualification'))
                    moreDataProvider.addItem(reIndustry.selectedItem);
            }
        ]]>
    </fx:Script>
    <s:layout>
        <s:VerticalLayout/>
    </s:layout>

    <s:Label x="538" y="130" text="Industry of Interest:"/>
    <s:List id="reIndustry" dataProvider="{recruitIndustries}" x="538" y="150" width="165" height="122" 
            labelField="industry" change="itemClickHandler(event)"/>
    <s:Label x="723" y="130" text="Qualifications:"/>
    <s:List id="reQualifications" dataProvider="{moreDataProvider}" x="723" y="150" width="165" height="122" 
            labelField="qualification"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12130045

复制
相关文章

相似问题

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