开发者

Flex 4 -- Call function when dataprovider changes

How can I set a function to be called when the length of a DataProvider开发者_运维问答 changes?


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/


If you're working with an ICollectionView (aka ArrayCollection), you could add an event listener for the "collectionChange" event.

Docs: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/ListCollectionView.html#event:collectionChange

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜