仅刷新数据提供者的一部分。可能?

时间:2013-03-15 18:39:34

标签: actionscript-3 flash flex4

是否可以仅刷新flex DataProvider中的一个项目?

例如,实现这样的目标

[Bindable]
private var nodes : VectorCollection = new VectorCollection();

/* thousands of insertions on nodes */

/* Triggered by some event */
public function nodeStatusChanged(nodeId : Number) : void {
      nodes.refresh(nodeId);
}
而不是做  每nodes.refresh()次电话会议nodeStatusChanged(nodeId)

有什么想法? 提前谢谢。

2 个答案:

答案 0 :(得分:1)

我不确定我是否完全理解你的问题是什么,但是如果你想在同时插入大量值时只收集一个事件,那么你应该使用中间向量:

var tempVector:Vector.<Node> = new Vector.<Node>();
// Do whatever you need to perform here;
nodes.vector = tempVector;
nodes.refresh();

使用向量使用的类名替换Node。 在refresh()方法中,您可以发送您的活动:

dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));

答案 1 :(得分:1)

你可以试试这个

要在vectorcollection中更新一个项目,您可以在ICollectionView中使用itemUpdated()

如果对象未实现IEventDispatcher接口,您还可以使用itemUpdated()方法通知集合对数据提供程序对象的更改;

[Bindable]
private var nodes:VectorCollection = new VectorCollection();

更新节点VectorCollection中的字段时,如下所示,控件不会自动更新,因此请使用itemUpdated()。

nodes.getItemAt(0).field1="someOtherValue";

nodes.itemUpdated(nodes.getItemAt(0));

Instead of nodes.refresh();