flex Dictionary dataProvider?
I have a Dictionary that I'd like to bind as the dataProvider for an mx:ComboBox. e.g., when I do this:
mydict[somenewkey]= somenewval;
I'd like the combobox to update its contents.
The problem is that Dictionary doesn't seem to be Bindable. If I were开发者_开发百科 using an Array, I'd use ArrayCollection. But there doesn't seem to be a corresponding DictionaryCollection or HashCollection. What to do?
A Dictionary is not the appropriate object for a dataProvider of a list based class.
I suspect your display problems have nothing to do with data binding, but rather other issues, such as a dictionary does not have a length property.
I suspect the ComboBox will treat your dictionary as a single object, not as a collection of multiple objects.
Try using an ObjectProxy:
http://www.adobe.com/livedocs/flex/3/langref/mx/utils/ObjectProxy.html
Isn't what you're looking for just a combination of the setItemAt and getItemIndex methods of the ArrayCollection?
_myAC.setItemAt( somenewval, _myAC.getItemIndex( somenewkey ) );
精彩评论