views:

517

answers:

2

I have a project that was compiled with the Flex 3.2 SDK.

One of my components is a combobox, which is bound to a property (called products) in the Cairngorm model. If I insert a new value into model.products, then the combobox immediately shows the new value. Works perfectly.

I then moved to the 3.5 SDK, and running the identical operation causes a problem. Even though the model has been updated (I have verified that this is definately the case), the combobox does not show the new value correctly - it seems to be aware that there is a new item because there is a new row in the combo, but the new row is blank and unselectable. The existing items in the combo are there and selectable (as they should be). If I re-initialising the form (i.e. close and re-open the TitleWindow on which the combo is located), then all the correct values (including the new one) are shown in the combo.

I have swapped back and forth a few times between 3.2 and 3.5 to verify that this is indeed the root cause.

Any idea on how to get around this would be greatly appreciated.

+2  A: 

Are you changing the dataProvider, or replacing it?

I have noticed that in the Flex 4 version of the Flextras AutoCompleteComboBox the ComboBox dataProvider sometimes get out of sync with the drop down's dataProvider. I figured this was all my fault due to the changes I made to add AutoComplete to the ComboBox.

It is entirely possible that this change was added in Flex 3.5; and I just didn't notice it until my Flex 4 adventures.

First, I'd try to invalidate the ComboBox when the dataProvider changes. You can do this by listening to the collectionChange event of the collection. In the event handler just do:

myCombo.invalidateProperties()
myCombo.invalidateDisplayList()

If you're repacing the dataPRovider, then you may try to override the set dataProvider method and add a line like this:

this.dropdown.dataProvider = value;

Is an odd issue. I believe in Flex 3 / 3.2 was that every time the dataPRovider changed the drop down was closed [destroyed] and re-created. It appears they stopped doing that at some point; which causes this anomaly.

www.Flextras.com
The dataProvider for the combo was set to a Bindable model (Cairngorm). So, updating the model in the command result automatically bubbled up to the combobox. Well, it used to anyway.Having tested a bit more, it seems that I have to reset the dataprovider:cb_products.dataProvider = model.products;Which kinda sucks.
JonoB
Actually, the above doesnt work. It seems that cb_products.dropdown.dataProvider = model.products does, however. Which still sucks.
JonoB
You're replacing the dataProvider with that code. There must be a fringe bug added to the ComboBox somewhere between 3.2 and 3.5 . You can probably extend the ComboBox and override the set dataProvider method to do this update internally so you don't have to do it manually.
www.Flextras.com
Pretty much confirmed to be a bug in 3.5.http://forums.adobe.com/thread/597632 https://bugs.adobe.com/jira/browse/SDK-25705https://bugs.adobe.com/jira/browse/SDK-25567I hate having to monkey patch
JonoB
I luckily already had extended the ComboBox into a custom component, which I use just about everywhere in my app, so it was just a matter of adding the following to my custom component: private var newDropDown:ListBase; override public function set dataProvider(value:Object):void { super.dataProvider = value; newDropDown = dropdown; if(newDropDown) { validateSize(true); newDropDown.dataProvider = super.dataProvider; } }
JonoB
+2  A: 
//this will replace the list base on an update
private var newDropDown:ListBase;

//This addresses a bug in flex 3.5 SDK 
//where the list base does reflect changes to the data provider
//forums.adobe.com/thread/597632  
//bugs.adobe.com/jira/browse/SDK-25705 
//bugs.adobe.com/jira/browse/SDK-25567
override public function set dataProvider(value:Object):void
{
    super.dataProvider = value;
    newDropDown = dropdown;

    if(newDropDown)
    {
        validateSize(true);
        newDropDown.dataProvider = super.dataProvider;
    }
}
JonoB