Flex 4 - 数据提供者更改时的调用功能

时间:2011-02-06 14:37:17

标签: flex flex4 dataprovider

如何在DataProvider的长度发生变化时设置要调用的函数?

3 个答案:

答案 0 :(得分:1)

使用事件“CollectionEvent.COLLECTION_CHANGE”:

是一个很好的解决方案

http://blog.flexexamples.com/2008/12/16/detecting-when-the-data-provider-of-a-datagrid-control-changes-in-flex/

答案 1 :(得分:0)

如果你正在使用ICollectionView(又名ArrayCollection),你可以为“collectionChange”事件添加一个事件监听器。

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

如果您在MXML文档中,则UI组件的dataProvider属性应该是数据绑定的源。所以你可以{myComponent.dataProvider.length}将值绑定到其他东西,如果那是用例。

答案 2 :(得分:0)

我能通过动作脚本代码进行绑定的唯一方法就是通过它。像这样:

protected function creationCompleteHandler(event:FlexEvent):void {
    BindingUtils.bindSetter(myHandleFunction, myList, "dataProvider");
}

myHandleFunction通过参数接收具有绑定属性类型的对象。

相关问题