You have a lot of stuff happening in there.  Did you debug it to see why
it was not working? Particularly the "computeSelectedDateRangeIndex()"
function?  Was it being called when you expected?  

 

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 

________________________________

From: [email protected] [mailto:[email protected]] On
Behalf Of Richard Rodseth
Sent: Monday, January 26, 2009 4:46 PM
To: [email protected]
Subject: [flexcoders] ComboBox selectedIndex revisited

 

I see there was another long thread about this problematic component
back in October (Dan Pride)

I don't see why this shouldn't work:

      <mx:ComboBox id="dateRangePresetCombo" 
          dataProvider="{this.availableRanges}" 
 
selectedIndex="{this.computeSelectedDateRangeIndex(this.selectedDateRang
ePreset, this.availableRanges)}"
          rowCount="{availableRanges.length}"  
          labelFunction="labelFunction" 
          change="onDateRangePresetSelected(event)" />    

where selectedDateRangeIndex() scans the available ranges, and
this.selectedDateRangePreset and this.availableRanges are bindable. But
it doesn't. When the component is first created, the combobox appears
with the first item selected (sometimes).

I believe Dan's workaround involved callLater(). I just had some success
with the following:             

      <mx:ComboBox id="dateRangePresetCombo" 
          dataProvider="{this.availableRanges}" 
 
selectedIndex="{this.computeSelectedIndex(this.selectedDateRangePreset,
this.availableRanges)}"
          rowCount="{availableRanges.length}"  
          labelFunction="labelFunction" 
          added="onComboBoxCreation(event)"
          change="onDateRangePresetSelected(event)" />  

where on onComboBoxCreation() calls computeSelectedIndex() and sets
dateRangePresetCombo.selectedIndex.

Doing it  on creationComplete rather than "added" results in flicker as
the item changes from item1, but using the added event seems to do the
trick.

I'm pretty sure there's a bug in ComboBox. Probably not invalidating
properties or the display list when it should.

Hope this helps someone, and please set me straight if I'm wrong.

 

Reply via email to