I have been experiencing this problem for some time now - the comboboxes in my Flex 4 application aren't changing to match the comboboxes' dataproviders. In other words, when a dataprovider changes for a combobox, the combobox's dropdown may still display data from the last dataprovider. This problem is intermittent and inconsistent. It seems to also be a problem for itemrenderer comboboxes inside datagrids, when the datagrids are sorted, or when the datagrids' dataproviders are changed.
I've tried doing various invalidate methods / validateNow() on the comboboxes, and it doesn't update the dropdowns.
Any help will be greatly appreciated ![]()
The issue can be fixed by updating the dropdown also along with the combobox. PFB a sample code snippet,
cmbSample.dataProvider = acData; cmbSample.dropdown.dataProvider = acData; where, cmbSample --> is the combo box acData --> is the arraycollection object with data Here, cmbSample.dataProvider = acData --> updates the combobox with new data and cmbSample.dropdown.dataProvider = acData --> updates the drop down of the combo box with new data Hope this will solve your issue.
Thank you for posting this solution arunbiji, however, this workaround is at best problematic.
It seems that when setting the dataProvider for both the ComboBox and the dropdown, the dropdown's width is not set correctly.
I've tried every combination of invalidateDisplayList(), invalidateSize(), invalidateProperties(), and invalidateList() on both the ComboBox and the dropdown to no avail.
I'm currently working around this by setting the dropdown's percentWidth to 100, but this is mostly dissapointing as the dropdown will be scaled to sizes smaller than the corresponding ComboBox to match the text width. I've also tried using comboBox.dropdown.width = comboBox.width, but this again provides unexpected results, sometimes setting the width of the dropdown to something greater than that the ComboBox!
I would love to move to SDK 4, unfortunately, flash player 10 saturation among my organization's clientele is not where it needs to be, and due to the size of their user bases, updating is a prohibitive process. Also, the move could potentially require a significant amount of rebuild, which may not be in the budget for my department.
Has anyone had success with setting the dataProvider for both the comboBox and the dropDown AND having the dropDown scale correctly? If so, can you please describe the workaround you've used?
Question to the adobe gurus: will updating from SDK 3.5 to 4.0 resolve the issue without moving to spark components (ie - can I release a version using SDK 4's halo components for those clients who do upgrade to FP 10?), or will the app have to be updated to use the spark component set in order to function as desired? Would updating to one of the nightly 3.x builds help us resolve this issue?
Many thanks.
I found this problematic as well, but if you bind your ComboBox's dataProvider to an ArrayCollection, and then update that ArrayCollection with your new values, invalidateSize of the ComboBox, then everything works fine. The problem comes with setting a new dataProvider on the controls.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var myAC:ArrayCollection = new ArrayCollection( [ 1, 2, 3, 4, 5 ] );
private var newAC:ArrayCollection = new ArrayCollection( [ "item 11", "item 12", "item 13", "item 14", "item 15" ] );
private function changeDataProvider():void
{
myAC.removeAll();
for each ( var item:* in newAC )
{
myAC.addItem( item );
}
myAC.refresh(); /* don't necessarily need to do this here, but it's good practice when updating an ArrayCollection */
myComboBox.invalidateSize();
}
// this will duplicate the clipping/resizing issue brought up.
// to see how this works, call this instead of "changeDataProvider" in the click handler of the button
private function changeDataProviderBad():void
{
myComboBox.dataProvider = newAC;
myComboBox.dropdown.dataProvider = newAC;
}
]]>
</mx:Script>
<mx:Button label="Change Data" click="changeDataProvider()" />
<mx:ComboBox id="myComboBox" dataProvider="{ myAC }" />
</mx:Application>
Hope that helps!
- Kevin
North America
Europe, Middle East and Africa
Asia Pacific