I think the arrays will need to be converted to some sort of simple objects,
the parent will need a children field that consists of myChildrenArray:
var _kid:Object = {type: myChildrenArray[0], name: myChildrenArray[1]};
var __mom:Object = {type: myParentArray[0], name: myParentArray[1], children:
new ArrayCollection([_kid])}
var companyData:ArrayCollection = new ArrayCollection([__mom]);
If you keep references to the ArrayCollection that makes up the children you
can insert/remove other children
- Ivo
----- Original Message ----
From: Terry Allen <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, August 27, 2008 10:08:37 AM
Subject: Re: [flexcoders] How do I enter 2 arrays into one arraycollection
Thank you both for your replies.
Tracy, if I were to concat() the two arrays, how would I be able to slip in
the children field in the first array that represents the data from the second
array.
Basically, I am attempting to populate a advancedDatagrid using the combination
of two amfphp arrays. The data needs to be in Hierarchial format such as this :
combinedArrayCollec tion(parentDataA rray, childrenDataArray)
This would allow me to populate the datagrid with a groupable title and do a
inlinerender of another adg with the children data from combinedArrayCollec
tion.
Maybe I am looking at this problem wrong since really all I need is to append
children:[arrayData ] to the first array to get it to work.
Do you have any advice on how I can accomplish this?
Thanks again for all of the help!
Terry
On Wed, Aug 27, 2008 at 1:10 PM, Tracy Spratt <[EMAIL PROTECTED] com> wrote:
Also, you could splice() or concat() the source arrays, then wrap the result in
ArrayCollection.
Tracy
________________________________
From:[EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com] On Behalf Of
Scott Melby
Sent: Wednesday, August 27, 2008 12:08 PM
To: [EMAIL PROTECTED] ups.com
Subject: Re: [flexcoders] How do I enter 2 arrays into one arraycollection
Brute force approach (not sure if it'll compile, but it'll get you close):
var combinedArray: Array = new Array();
for each(var obj:Object in array1)
{
combinedArray. push(obj) ;
}
for each(obj in array2)
{
combinedArray. push(obj) ;
}
myArrayCollection. source = combinedArray;
hth
Scott
--
Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlane sw.com
tallen_eit wrote:
> Hello,
>
> I am trying to use 2 arrays I generate from a mySql database to
> populate an AdvancedDataGrid. I need to be able to use the following
> format but replace the static data with the two arrays I receive from
> AMFPHP.
>
> (I pulled the following snippet from Peter Ent's blog (thank you Peter!)
>
>
> [Bindable]
> private var companyData: ArrayCollection = new ArrayCollection(
> [
> {type:"department", title:"Engineering", children: new
> ArrayCollection(
> [
> {type:"employee", name:"Erin M"},
>
> {type:"employee", name:"Ann B"} ] ) },
>
> ] );
>
>
> How could I place the following arrays in the statement above?
> Parent = myParentArray
> children = myChildrenArray
>
> Thank you,
>
> Terry Allen
>
>
>
>
>