2 Replies Latest reply on Jul 17, 2006 4:21 AM by Lu_BaoGuo

    ComboBox select Item

    MichaelDiederich
      Hi all,

      i have a combobox with n entities - and on init i want to select e.g. the second entity. I tried to use selectedItem, getChildAt and and and.. and it doesn't work.

      Please give me a hint how to get this working!

      Thanks,

      Michael
        • 1. Re: ComboBox select Item
          meticoolus
          I guess, your requirement is to select second element from combo box on page load .if I am not wrong.
          If my anticipation is right then,here i go,
          you just have to call the init method in Application tag using initialize or creationComplete.
          like,
          <mx:Application ...........initialize= "init();">
          (note: if initialize doesnt work use creationComplete = "init() )

          //define init method as
          <mx:Script>
          function init()
          {
          comboID.selectedIndex=2;
          }
          </mx:Script>
          .
          .

          <mx:ComboBox id="comboID" ....../>
          .
          .

          </mx:Application>

          Hope this is useful.
          • 2. Re: ComboBox select Item
            Lu_BaoGuo
            function preSetItemCombox(obj:Object,DefaultItem:String){
            var aDP:Array = mx.utils.ArrayUtil.toArray(obj.dataProvider);
            var sDataValueInit:String = DefaultItem;
            var sDataValueCur:String;
            for ( var i:Number=0; i<aDP.length; i++ ) {
            sDataValueCur = aDP .data;
            if ( sDataValueCur == sDataValueInit) {
            obj.selectedIndex = i;
            }
            }
            }