No this is not the scenario i want to have initially a value selected
when the combobox is shown.


--- In [email protected], Scott Melby <[EMAIL PROTECTED]> wrote:
>
> It seems you are asking how to change your code so that your combo box 
> selectedIndex property gets updated each time your model changes.  For 
> demo purposes you could just do something like the following:
> 
> /**
> * Returns the index of the
> */
> private function
getSelectedProductSubTypeIndex(selectedProduct:Product):int
> {
>     //TODO: in real system search the selectedProduct for the correct 
> sub type and return correct index
>     //the thing to search for could be passed as a param as well
>     return 1;
> }
> 
> <mx:ComboBox id="productSubTypeCB" width="160"
> 
> dataProvider="{selectedProduct.typeNames}"
> selectedIndex="{this.getSelectedProductSubTypeIndex(selectedProduct)}"
> change="productOffer.productSubType = event.currentTarget.value" />
> 
> 
> Assuming your productType member is Bindable this method will get 
> triggered (due to it having a parameter that is bindable) every time an 
> assignment is made to productType (like your model changes), since it 
> always returns 1 your selected index will be set for you.
> 
> hth
> Scott
> 
> Scott Melby
> Founder, Fast Lane Software LLC
> http://www.fastlanesw.com
> 
> 
> 
> gur_sukh wrote:
> >
> >
> > The combobox dataprovider sets selectedindex to 0. How do we set it to
> > something else.
> >
> > AS the dataprovider is bound to model and every time it changes the
> > selected index is 0.
> >
> > For demo purposed i need to set this to 1.
> >
> > <mx:ComboBox id="productSubTypeCB" width="160"
> > dataProvider="{selectedProduct.typeNames}"
> > selectedItem="1"
> > change="productOffer.productSubType = event.currentTarget.value" />
> >
> >
>


Reply via email to