Flex ComboBox not updating when dataProvider updates

This is something that should work in Flex, but it is not because of some internal bug.

I had a ComboBox binded on an Array of items. Sometimes it would update the ComboBox whenever a new item was added, and sometimes it would not. The behavior just wasn’t very consistent.

There are many posts about this, but the short solution I tried was to just use an ArrayCollection() instead of an Array() as my binded source. Also, whenever I updated the ArrayCollection, I called the “refresh()” method for the ArrayCollection and also called the “validate()” method for the combobox. Try those three and see what happens!

Advertisements

3 thoughts on “Flex ComboBox not updating when dataProvider updates

  1. The ArrayCollection is actually a wrapper class for the Array to allow just these sorts of things. The Adobe Flex team kept the Array as basic as possible, then used the ArrayCollection to fire off “collectionChange” events. Whenever you want something to happen when an array element changes, just use the ArrayCollection class, or, if you have an array within a class you wrote, you can fire off the binding yourself (using the getter and setter in the class), and get the display to update your combobox also.

  2. Hi Gareth,

    Wasn’t aware of that difference between Array and ArrayCollection. It makes sense now – guess its not a bug, its a feature 🙂

    Thanks for the tip!

  3. I tried changing it to ArrayCollection
    Still it doesnt work.,
    profilesArrayCol is the arraycollection which I gave
    Still it doesnt give me all updates which I do

    Please leave a reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s