Except that assumes the dataProvider for the ComboBox is an array of
simple values, which is often/usually not the case.

 

Also, break; the loop inside the if().  No point in continuing the loop
once the match is found.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of danielvlopes
Sent: Friday, December 28, 2007 2:30 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Sugestion for ComboBox component

 

Hello Tracy, i made exactly this, extended and use this function:

public function setComboItem(combo:String,item:String):void{
for(var i:Number = 0; i < this[combo].dataProvider.length; i++)
{
if(this[combo].dataProvider[i] == item){
this[combo].selectedIndex = i;
} 
}
}

But i'm think this is good think to be inside original comp.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Extend combobox yourself, add this functionality, it is not difficult.
> You only need to do it once. And there are components available that
do
> this, I have one that is part of an item renderer, here:
> 
>
http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectI
<http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&object
I> 
> D=767 It is just an example, not a production level component, the
main
> problems are with the renerder part, defining the row-level
dataProvider
> for the combo drop down. Take that out and it gets much simpler.
> 
> 
> 
> One issue with doing it generically is specifying which property of
the
> ComboBox dataProvider item to use for the match. You may not be
matching
> on the "label". See how I handled it im my example.
> 
> 
> 
> Tracy 
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of danielvlopes
> Sent: Friday, December 28, 2007 1:32 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Sugestion for ComboBox component
> 
> 
> 
> Hello everybody, i want make a sugestion for Adobe Flex Team, and i
> know some members of Flex team participate here, in my projects when i
> use combobox to recover data from database and selected item of this
> combo must be set to the data recorded in database i do loops in
> entire dataprovider to find the value and your index to use
> selectedIndex to receive this index.
> 
> This is very common when you use combo to add and edit data in
> database and i think everybody need this, why adobe don't incorpore
> some new method in next release for do this? Something like
> setSelectedLabe(label:String) ...
>

 

Reply via email to