dbasch
asked on
Multiple ArrayCollections with Single Data Source
Hi All,
This should be a pretty simple question.
Say that I declare two different ArrayCollection's that use the same Array as their source. Then I insert an item into one of those ArrayCollections.
Is the inserted item pushed to the source Array? Does the second ArrayCollection receive a CollectionChange.ADD event?
For instance, I would like to have two different sort's applied to the same Array by using two different ArrayCollections.
I did find this blog post that states something like this is possible:
http://frankieloscavio.blogspot.com/2008/04/using-multiple-arraycollections-with.html
But, there is no example given.
Thanks for all the help,
Derek Basch
This should be a pretty simple question.
Say that I declare two different ArrayCollection's that use the same Array as their source. Then I insert an item into one of those ArrayCollections.
Is the inserted item pushed to the source Array? Does the second ArrayCollection receive a CollectionChange.ADD event?
For instance, I would like to have two different sort's applied to the same Array by using two different ArrayCollections.
I did find this blog post that states something like this is possible:
http://frankieloscavio.blogspot.com/2008/04/using-multiple-arraycollections-with.html
But, there is no example given.
Thanks for all the help,
Derek Basch
// the list that displays the user defined sorted ArrayCollection
// the second ArrayCollection remains sorted by stuffId
// for add/delete item efficiency
<?xml version="1.0" encoding="utf-8"?>
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml"
dataProvider="{stuffSortedByUserDefinedCollection}"
>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
public var stuff:Array = new Array();
public var stuffSortedByStuffIdCollection:ArrayCollection = new ArrayCollection(stuff);
[Bindable]
public var stuffSortedByUserDefinedCollection:ArrayCollection = new ArrayCollection(stuff);
]]>
</mx:Script>
</mx:List>
// The data insert
public function setStuff( stuff:stuffVO ):void
{
if (! this.getStuff(stuff.StuffId)) {
this.stuffCollectionSortedByStuffIdViewCursor.insert( stuff );
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.