1 Reply Latest reply on Jan 15, 2008 1:42 PM by Garyl Woolworth

    Selecting from Combobox with only one item

      I'm populating Comboboxes based on selections from other comboboxes. I pick up the selection with the 'change' trigger, however when you select the top item or if there is only one item, the change route doesn't work. So I tried to use the 'click' and even the 'close' triggers instead, but they give me an errors when I try to access the companion ArrayCollections which hold the IDs for the items in the list (as commented in the code). Any ideas how to get this to update with just one selection?

      <!-- The first three comboboxes populate the next one in the list in a 'drilldown' approach -->
      <mx:ComboBox minWidth="130" maxWidth="130" id="selectSys" dataProvider="{sysOps.lastResult.system.data}"
      change="fillComboBox(selectSys, selectSub, 'subsystem', subOps, sysIDs, 1)" rowCount="10" />
      <mx:ComboBox minWidth="130" maxWidth="130" id="selectSub" dataProvider="{subOps.lastResult.system.data}"
      change="fillComboBox(selectSub, selectDev, 'devices', devOps, subIDs, 2)"/>

      <mx:HTTPService id="sysOps" useProxy="false" method="GET"
      result="sysIDs = sysOps.lastResult.system.id as ArrayCollection;"
      url=" http://localhost:8080/TomCustodes/rocket"/>
      <mx:HTTPService id="subOps" useProxy="false" method="GET"
      result="subIDs = subOps.lastResult.system.id as ArrayCollection;"
      url=" http://localhost:8080/TomCustodes/rocket"/>

      // fill destination combobox based on selection from src combobox
      public function fillComboBox(src:ComboBox, dest:ComboBox, type:String,
      serv:HTTPService, idArray:ArrayCollection, element:int) : void {

      // choose ID from the associated ID array with the same selecetedIndex
      // error occurs as the idArray ArrayCollection comes up as null
      var selectedID:String = idArray.getItemAt(src.selectedIndex) as String;

      var params:Object = {};
      params[type] = type;
      var arg:String = "arg";
      var argList:Array = new Array();
      if (element > 1) {
      var ind:int = selectSys.selectedIndex;
      var sysName:String = sysIDs.getItemAt(ind) as String;
      if (element > 2) {
      ind = selectSub.selectedIndex;
      var subName:String = subIDs.getItemAt(ind) as String;
      params[arg] = argList;


        • 1. Re: Selecting from Combobox with only one item
          Garyl Woolworth Level 1
          I think the way I would go about that is having a result function for the HTTPServices and set your array collections how you are. Then after they are set I would check to see if the length == 1 and if it does then recall your fillComboBox method for the next combo box since there isn't a way for the user to change the combo box they might as well have the next one already filled out. The other approach you could take is after you set your array collection to your result add dummy items via myAC.addItemAt({label:"Choose one"}, 0); This will ensure the user always has an item to change to.