3 Replies Latest reply on Dec 21, 2010 3:21 PM by saisri2k2

    Enumerate Dropdownlist

    Zolotoj Level 3

      My Dropdownlist has a dataProvider with the following fields:


      name, id


      The control shows names while the key value is ID.

      I am using data model to carry data between the front-end and back-end. How do I set selectedItem of the control to match the id value from the model?



        • 1. Re: Enumerate Dropdownlist
          saisri2k2 Level 4

          we use the following utility


          public static function populateCombo(combo:DropDownListBase,array:ArrayCollection,defaultId:String,property:String='id'):void{
                         var oSelectedItem:Object          = null;
                         for each(var obj:Object in array){
                              if(obj[property] == int(defaultId)){
                                   oSelectedItem = obj;
                              combo.selectedItem = oSelectedItem;
                              combo.selectedIndex = 0;

          • 2. Re: Enumerate Dropdownlist
            Zolotoj Level 3

            How do I call this function?

            • 3. Re: Enumerate Dropdownlist
              saisri2k2 Level 4

              From ur question im thinking that u need to select a item in the combo

              box by using the value that is in the model.( combo has a data



              Here is the explanation.  Pass the function with the combo box ref,

              array collection - the data provider of the combo, id that u want to

              set as selected, leave the last column alone.


              When the function is called with all the values mentioned above.. It

              will set the selected item with the item id that u hav in the

              model..you donhav to do anything else.