Flex 3.5.0; Refresh ComboBox display list when data changes

I have two related ComboBoxes (continents and countries). When the ComboBox continents change, I request XML from a specific URL. When I get this XML, I change the DataProvider for ComboBox countries, for example:

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

I am sending ListEvent.CHANGE because I use it to change another ComboBox, so please ignore this (and 1st line).

So my problem is this: I select "ASIA" from the first continents, and then the list message is updated (I see this because the first ITEM element is an element labeled "23 countries"). I click on combos and then I see countries.

NOW, I select "Africa", the first item is displayed when the ComboBox closes, and then when I click on it, the countries still remain in Asia. In any case, if I clicked an item in the list, then the list will be updated correctly, and it will also have the correct information (as I said, this affects other ComboBoxes). The only problem is that the display list is not updated.

In this function I tried these approaches

  • Convert XMLList to XMLCollection and even ArrayCollection

  • Adding this.resellersCountry.invalidateDisplayList ();

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

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

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

+5
4

dataprovider comboBox, , .

this.resellersCountry.dataProvider = items;
this.resellersCountry.dropdown.dataProvider = items;
+11

this.resellersCountry.dropdown.dataProvider = items;

(Flex SDK 3.5)

, ​​ 4.0

+1

:

ComboBox, BindingUtils :

MXML:

<mx:ComboBox id="cb_fontFamily"
        width="100%"
        dataProvider="{ model.fontFamilies }" />

Script:

private function init():void
{
    BindingUtils.bindSetter(updateFontFamilies, model, "fontFamilies");
}

private function updateFontFamilies(fontFamilies:ArrayCollection):void
{
    if (cb_fontFamily != null) cb_fontFamily.dropdown.dataProvider = fontFamilies;
}

.

+1

, Adobe, , ArrayCollection ComboBox ( ) :

items.removeAll();
for each (var item:* in newItems)
{
    items.addItem(item);
}
0
source

All Articles