2 Replies Latest reply on Feb 12, 2008 2:13 PM by Peter deHaan

    Link combo boxes

    derm116
      Hi all,



      I'm writing a flex app which takes in something like the following xml

      <VersionList>
      <Version>
      <Release name="7.11.0">
      <Snap name="S05"/>
      <Snap name="S11"/>
      <Snap name="S12"/>
      <Snap name="S14"/>
      </Release>
      </Version>
      <Version>
      <Release name="7.12.0">
      <Snap name="S12"/>
      <Snap name="S19"/>
      <Snap name="S28"/>
      </Release>
      </Version>
      </VersionList>


      I have 2 combo boxes - 1 which holds the version release names and another which holds the snap names!

      What I want to do is populate the version combo box and depending on what is chosen, populate the snap combo box
      Ex: if the user selected 7.12.0 - the snap box would display s12, s19, s28!

      I have my mxml file set up to take in the xml file and load the release names into an array to populate the version box! Does anyone know how I could populate the snap combobox depending on what is chosen in the version box???

      Thanks a mil in advance, any help would be greatly appreciated!
      Cheers,
      Derm
        • 1. Re: Link combo boxes
          derm116 Level 1
          Hi all,

          I actually got this working using xmlLists and xmlListCollections. In case anyone else is wondering how to do it...

          I used the following pairs of xmlLists and xmlListCollections

          //Create an XML list object to hold all the version values
          versionList = myXML.Version.Release.attributes();

          versionListCol = new XMLListCollection(versionList);

          //Create an XML list object to hold all the snap values
          snapList = myXML.Version.Release[-1].Snap.attributes();

          snapListCol = new XMLListCollection(snapList);

          And the following refresh function

          private function refreshSnaps() :void {

          //Use filtering on the version name to create the xmlList object
          snapList = myXML.Version.Release.(@name == versionBox.selectedLabel).Snap.attributes();

          snapListCol = new XMLListCollection(snapList);
          } //end function refreshSnaps

          and then my combo boxes looked like

          <mx:ComboBox x="138" y="40" dataProvider="{versionList}" id="versionBox" prompt="Please select a version..." change="refreshSnaps()"/>

          <mx:ComboBox x="138" y="74" dataProvider="{snapList}" id="snapBox" prompt="Please select a snap..." width="186"/>
          • 2. Re: Link combo boxes
            Peter deHaan Level 4
            derm116,

            You could also try something like the following: