How can I set a function to be called when the length of a DataProvider changes?
Flex 4 -- Call function when dataprovider changes
3.8k views Asked by Anonymous1 At
3
There are 3 answers
0
On
If you're working with an ICollectionView (aka ArrayCollection), you could add an event listener for the "collectionChange" event.
If you are inside an MXML document the dataProvider property of the UI component should be a source of data binding. So you could just {myComponent.dataProvider.length} bind the value to something else if that is the use case.
0
On
The only way I could get thru it was making a binding in the actionscript code. Something like this:
protected function creationCompleteHandler(event:FlexEvent):void {
BindingUtils.bindSetter(myHandleFunction, myList, "dataProvider");
}
myHandleFunction receives by parameter an object with the type of the binded property.
Here is a good solution using the event "CollectionEvent.COLLECTION_CHANGE" :
http://blog.flexexamples.com/2008/12/16/detecting-when-the-data-provider-of-a-datagrid-control-changes-in-flex/