6 Replies Latest reply on May 14, 2009 4:23 PM by Flex harUI

    Custom Combobox "selectedItem" problem

    srini kusunam

      Problem:

      "selectedItem" sometime works and sometime doesn't in custom combobox.

       

      Architecture:

      I have a "Search" screen and after user enters Search Criteria and hit "Search" button it goes through Cairngorm Event to Command to Delegate and then retrieve VO from DB and assign it to Model and then view is forwarded to "Display" screen where i have around 13 custom combo boxes. Each custom combo box look like following:

       

      <!-- MXML with a Cusotm Combobox --->

      <custom:CustomSelectedComboBox id="vehicleTypeCB"

                               dataProvider="{__model.initializerVO.vehicleTypeList}"

                               labelFunction="displayCodeAndDescription"

                               selectedItem="{__model.updateVO.vehicleType}"

                               prompt="Select one..."/>

       

      <!-- Cusotm Combobox --->

       

       

       

       

       

       

       

       

       

       

      public class CustomSelectedComboBox extends ComboBox
      {
           public function CustomSelectedComboBox()
           {
                super();
                this.rowCount = 10;
           }
           // value is the value you input that you want to search for.
           override public function set selectedItem(value:Object):void
           {
                if (value != null && selectedIndex == -1)
                {
                     /** do a painful search */
                     for each(var item:Object in this.collection)
                     {
                          //Vdata is the Arraycollection item you whant to search in.
                          //So VData is the name of the item within the ArrayCollection
                          if (item.code == value )
                          {
         super.selectedItem=item;
                              break;
                          }
                     }
                }
           }
      }

       

       

       

       

       

       

       

       

       

       

      If i put just 1 custom combobox instead of 13 it works fine but if i put all 13 only 2 or 3 shows up fine.

       

      I am sure there is something i am missing which causing this weird behavior. I appreciate any help.