Adobe Flex Combobox DataProvider
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 (cal开发者_开发问答led 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.
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.
//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;
}
}
精彩评论