2012-08-26 38 views
0

我真的新使用Flex,並試圖數據2個列表選擇組合(見下面的代碼):Flex的綁定列表將selectedItem

<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」列表中。

這裏是我的數據:

<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」顯示。

+1

但有業內每隻有一個資格。爲什麼你需要在列表中表示? – RIAstar

回答

0

@RIAstar問題是否正確。

你可以做到這一點下面的代碼: -

<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"/> 
相關問題