Flex 3.5.0; Update ComboBox display list upon dataprovider change

Posted by Gabriel Poama-Neagra on Stack Overflow See other posts from Stack Overflow or by Gabriel Poama-Neagra
Published on 2010-03-30T14:33:31Z Indexed on 2010/05/22 20:20 UTC
Read the original article Hit count: 671

Hello,

I have two related ComboBoxes ( continents, and countries ). When the continents ComboBox changes I request a XML from a certain URL. When I receive that XML i change the DataProvider for the countries ComboBox, like this:

public function displayCountryArray( items:XMLList ):void
        {
            this.resellersCountryLoader.alpha = 0;
            this.resellersCountry.dataProvider = items;
            this.resellersCountry.dispatchEvent( new ListEvent( ListEvent.CHANGE ) );
        }

I dispatch the ListEvent.CHANGE because I use it to change another ComboBox so please ignore that (and the 1st line ).

So, my problem is this: I select "ASIA" from the first continents, then the combobox DATA get's updated ( I can see that because the first ITEM is an item with the label '23 countries' ). I click the combo then I can see the countries.

NOW, I select "Africa", the first item is displayed, with the ComboBox being closed, then when I click it, the countries are still the ones from Asia. Anyway, if I click an Item in the list, then the list updates correctly, and also, it has the correct info ( as I said it affects other ComboBoxes ). SO the only problem is that the display list does not get updated.

In this function I tried these approaches

  • Converting XMLList to XMLCollection and even ArrayCollection

  • Adding this.resellersCountry.invalidateDisplayList();

  • Triggering events like DATA_CHANGE and UPDATE_COMPLETE I know they don't make much sense, but I got a little desperate.

Please note that when I used 3.0.0 SDK this did not happen.

Sorry if I'm stupid, but the flex events are killing me.

© Stack Overflow or respective owner

Related posts about flex3

Related posts about combobox