Reputation: 45104
Is it possible to refresh only one item in a flex DataProvider?
For example, achieving something like this
[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);
}
instead of doing nodes.refresh()
on every nodeStatusChanged(nodeId)
call.
Upvotes: 1
Views: 150
Reputation: 36127
You can try with this
For update one item in vectorcollection you can use itemUpdated()
in ICollectionView.
You can use also use the itemUpdated() method to notify the collection of changes to a data provider object if the object does not implement the IEventDispatcher interface;
[Bindable]
private var nodes:VectorCollection = new VectorCollection();
When you update a field in the nodes VectorCollection, as follows, the control is not automatically updated so use itemUpdated().
nodes.getItemAt(0).field1="someOtherValue";
nodes.itemUpdated(nodes.getItemAt(0));
Instead of nodes.refresh();
Upvotes: 1
Reputation: 714
I'm not sure I fully understand what your problem is, but if you want only one event to be dispatched by your collection when inserting a lot of values at the same time, then you should use an intermediary vector:
var tempVector:Vector.<Node> = new Vector.<Node>();
// Do whatever you need to perform here;
nodes.vector = tempVector;
nodes.refresh();
Where you replace Node by the classname you use with your vector.
In your refresh()
method, you then dispatch your event:
dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
Upvotes: 1