it is expected, but i just don't know how to fix it.... how do you set
something selected in a component after you receive new data?

but i figured it out... 

thanks to a post by ben forta... the post wasn't what i wanted or
needed, but there is no fun when you don't have to try.... 

so what you have to do is extend the List, or comboBox components.... 

create a new component based on the list or combo box... and in that
component put the following code...

<?xml version="1.0" encoding="utf-8"?>
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml";>
        <mx:Script>
                <![CDATA[
                        private var tempSelectedIndex:Number = -1;
                        private var bDataProviderSet:Boolean = false;
                        
                        // Trap dataProvider being set
                        override public function set 
dataProvider(o:Object):void{
                                tempSelectedIndex = this.selectedIndex;
                                // invoke ComboBox version
                                super.dataProvider = o;
                                
                                // This may get called before dataProvider is 
set, so make sure
not null and has entries
                                if (o!=null && o.length){
                                        // Got it, set flag
                                        bDataProviderSet = true;
                                }
                                this.selectedIndex = tempSelectedIndex;
                        }
                        
                ]]>
        </mx:Script>
</mx:List>

i set a temporary selected index to whatever is passed, other wise
it's a "-1" then after the dataprovider is set, i reset the selected
index back to what it was, because the setting of the dataprovider is
what empty's the value.

I understand why it does it... but in coldfusion, you have select
boxes... and you have <cfif> within the select box stating that if the
value is equal to whatever you want to be selected then select it.... 

even if you tried that in this case... it would work on
creationComplete, but everytime you call it there after, it would be
blank... because the setting of the dataprovider erases whatever is in
there... 
--- In [email protected], Tom Chiverton <[EMAIL PROTECTED]>
wrote:
>
> On Tuesday 30 Jan 2007, jensen.axel wrote:
> > so i'm binding to a custom class that i made, that grabs the current
> > price range of the house... but whenever my dataprovider changes, the
> > selected index is lost...
> 
> I'd say this was expected.
> If the user has '200-300' selected, and you update the data provider
to one 
> that doesn't have that as an option, it wouldn't make sense to
select some 
> random element in the new data.
> 
> -- 
> Tom Chiverton
> Helping to preemptively initiate visionary CEOs
> 
> ****************************************************
> 
> This email is sent for and on behalf of Halliwells LLP.
> 
> Halliwells LLP is a limited liability partnership registered in
England and Wales under registered number OC307980 whose registered
office address is at St James's Court Brown Street Manchester M2 2JF.
 A list of members is available for inspection at the registered
office. Any reference to a partner in relation to Halliwells LLP means
a member of Halliwells LLP. Regulated by the Law Society.
> 
> CONFIDENTIALITY
> 
> This email is intended only for the use of the addressee named above
and may be confidential or legally privileged.  If you are not the
addressee you must not read it and must not use any information
contained in nor copy it nor inform any person other than Halliwells
LLP or the addressee of its existence or contents.  If you have
received this email in error please delete it and notify Halliwells
LLP IT Department on 0870 365 8008.
> 
> For more information about Halliwells LLP visit www.halliwells.com.
>


Reply via email to