Many seems to be stumble upon this problem. Very similar to Object not dispatching any event for property value changes Array also doesn't dispatch any event for items added/deleted from it. Due to this when an object or array is used in the dataProvider of a list based control or comboBox etc any updates to the object or array would not get reflected in the UI.
The following sample should make it clear.
The first DG is fed with a ArrayCollection of Objects and the second DG has ObjectProxies. Select a item in the DGs and edit the values displayed in the text inputs. To complete the editing hit "Enter". Notice that in the first DG the values don't get reflected immediately where as in second DG it does.
To support Object based dataProviders the list based controls in Flex make a explicit call to ICollectionView.itemUpdated() to force a change event. This is the reason edits in list based controls get propagated to other list based controls when both of them are using the same colletion as input.
The source is here.
As noted in the forum discussion, when HierarchicalData is built using Objects/Arrays (to represent children) the changes to the Array would not get propagated to ADG. Hence it is necessary to construct the HierarchicalData using ObjectProxies and ArrayCollections.
2 comments:
Just a note about this:
When you set the properties of the ObjectProxy with the dot notation (e.g. "dg1.selectedItem.fname = fname1.text") everything works fine.
However if you want to set the properties using square bracket notation, make sure that the context of the object is ObjectProxy. E.g. THIS WON'T UPDATE:
var foo:Object = dg1.selectedItem;
foo["fname"] = fname1.text
This will:
var foo:ObjectProxy = dg1.selectedItem;
foo["fname"] = fname1.text
Belay that. That doesn't make any difference.
Post a Comment