I'm using Flex 3 and I have an AdvancedDataGrid whose dataProvider is a HierarchicalData based on an ArrayCollection.
The ArrayCollection contains basic Objects, which themselves contain a 'children' property, which is an ArrayCollection again.
If I set the 'children' property of one of these objects to a brand new ArrayCollection, the change is not reflected on my AdvancedDataGrid. From what I've read I think this might be because the datagrid is listening for CollectionChange events, which any ArrayCollections will fire. But, since I am changing a property on one of my 'objects' in this case (not an ArrayCollection), I think I somehow need to dispatch the same sort of event from my object, so that the datagrid knows to refresh the way that object (and its children) are displayed.
How can I do this? This is what I've tried:
myObject.children = <some new ArrayCollection>;
// OK, myObject has been changed, so need to tell the AdvancedDataGrid about the change
var colChangeedEvent:Event = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE, fileStructure);
But, it doesn't seem to do anything. I'm basically trying to tell the datagrid that it needs to refresh itself because of an Object change.
I'm very new to Flex and completely stuck right now so any help would be really appreciated.
Update: I've inspected the <dataGrid>.<dataProvider>.<source> property in the Eclipse debugger, and it contains the correct items.
It just doesn't display them in the grid. There must be some way to get it to refresh?
After seeing some other posts, I changed my dataProvider is one of these so I know that an event is being fired, but it doesn't seem to be enough to trigger the grid to refresh what it displays:
public class MyHierachicalData extends HierarchicalData
override public function set source(value:Object):void
Alert.show("Source changed, Firing an event... hopefully this will refresh the grid...");
super.source = value;
var event:CollectionEvent =
new CollectionEvent(CollectionEvent.COLLECTION_CHANGE) ;
event.kind = CollectionEventKind.RESET;