Changing DataProvider in a Flex ComboBox Problem Fix

I have stumbled across an old fix I found for a problem I had with an mx:ComboBox ages ago and thought it worth while blogging about. Basically I found that if I bound an ArrayCollection to the dataprovider of a ComboBox and then changed the contents of the ArrayCollection, the ComboBox would not update? I tried all sorts of things i.e. itemUpdated() on the provider/collection, invalidateProperies/DisplayList on the ComboBox and so on to no avail. I originally found that setting the prompt attribute in the ComboBox caused the issue but on building a quick example application I found that with or without the prompt it still fails to update. In fact its even odder without a prompt, the selected item changes but not the content within the dropdown???

So the solution is when you change the ArrayCollection assigned as the data provider to the ComboBox then assign the collection to the list control data provider for the ComboBox using the dropdown attribute, for example:

if(fixedCB.dropdown) fixedCB.dropdown.dataProvider=value;

Here is an example I have done to highlight the issue, change the data provider using the top button and notice the following:

1) First ComboBox the selected item changes but the rest of the list does not (can be sporadic in it’s occurrence)?
2) Second ComboBox the list does not change at all?
3) The third ComboBox should now be fixed.

* Note * The faulty ComboBoxes will work if you have a selected item first!

This entry was posted in General. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

10 Comments

  1. Tahir Awan
    Posted June 4, 2010 at 6:41 pm | Permalink

    I recently came across this bug. I fixed it by using the following code.
    dpArrayCollection.removeAll();
    dpArrayCollection.addAll( resultsArrayCollection );

  2. Posted June 10, 2010 at 1:45 pm | Permalink

    Your example gives a 404 error.

  3. Shane
    Posted July 7, 2010 at 1:01 am | Permalink

    Thank you, this was driving me crazy…

  4. Posted July 15, 2010 at 9:13 am | Permalink

    The 404 is now fixed @kyledodge thanks for the heads up!

  5. Elena
    Posted July 19, 2010 at 2:59 pm | Permalink

    Thanks, your post was very helpful, I also struggled with this bug.

  6. icaroqr
    Posted July 21, 2010 at 2:42 pm | Permalink

    ————————————————————————
    dpArrayCollection.removeAll();
    dpArrayCollection.addAll( resultsArrayCollection );
    ————————————————————————
    TANX MAN! IT WORKS!

  7. Nuwan Chamara
    Posted August 18, 2010 at 5:34 am | Permalink

    Thank you so much for this example….

  8. Borman
    Posted August 19, 2010 at 2:09 pm | Permalink

    Guys, can anybody confirm, that this issue doesn’t exist in SDK 3.4?
    Thanks!

  9. Posted August 23, 2010 at 1:07 pm | Permalink

    @Borman from what I can recall the problem exists throughout all version 3 SDK releases!

  10. Schmuli
    Posted August 29, 2010 at 3:40 pm | Permalink

    I had this issue too, and setting the drop-down’s data-provider worked fine. It is my understanding that in the 3.6 updates of the framework, this has been fixed, however I can’t use that build so I can’t be sure. Thanks for a solution, even if (hopefully) it is only temporary.

2 Trackbacks

  1. [...] This post was mentioned on Twitter by Simon Bailey, MojoGeeks. MojoGeeks said: Changing DataProvider in a Flex ComboBox Problem Fix: I have stumbled across an old fix I found for a problem I ha… http://bit.ly/b0m2uT [...]

  2. [...] Changing DataProvider in a Flex ComboBox Problem Fix http://www.newtriks.com/?p=935 [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • FreeAgent sign-up


  • Recent Posts

  • Categories