So I am trying to build a MPTT (nested tree) object in php, I have a
few questions for this group because I am not sure how the data should
be returned. I have been using static data and have a few questions
on what is contained within the data. Here is my arraycollection:
private var myDataProvider:ArrayCollection = new ArrayCollection([
Region:"Southwest",ID:"1",Territory_Rep:"Tom Jones", children: [
{Region:"Arizona",ID:"2", children: [
{Territory_Rep:"Barbara Jennings", ID:"3"},
{Territory_Rep:"Dana Binn",ID:"4"}]},
{Region:"Central California",ID:"5", children: [
{Territory_Rep:"Joe Smith", ID:"6"}]},
{Region:"Nevada", ID:"7", children: [
{Territory_Rep:"Bethany Pittman",ID:"8"}]},
{Region:"Northern California", ID:"9", children: [
{Territory_Rep:"Lauren Ipsum",ID:"10"},
{Territory_Rep:"T.R. Smith",ID:"11"}]},
{Region:"Southern California",ID:'12', children: [
{Territory_Rep:"Alice Treu", ID:'13'},
{Territory_Rep:"Jane Grove",ID:"14"}]}
]}
]);
I am in need of some guidance, so bear with me :). I think that this
is an object {Territory_Rep:"Joe Smith", ID:"6"}, is this an array
with an object {Region:"Central California",ID:"5", children: [
{Territory_Rep:"Joe Smith", ID:"6"}]} ?
Here is my problem, I am creating some php data returns to flex with
arrays, object, assoc arrays. I am not sure what a flex
arraycollection is so I am running some tests. Here are some tests
that I have done,
Example #1
PHP CODE
$o1->name = 'Tom';
$o1->status = 'Dad';
$o2->name = 'Wendy';
$o2->status = 'Daughter';
$b[] = $o2;
$o1->child = $b;
$arr[] = $o1;
return $arr;
Charles Proxy Sees This:
com.mptt.MPTT.GetTree
Parameters
Results
[0]
name
status
child
[0]
name
status
Example #2
$o1->name = 'Tom';
$o1->status = 'Dad';
$o2->name = 'Wendy';
$o2->status = 'Daughter';
$o1->child = $o2;
$arr[] = $o1;
return $arr;
com.mptt.MPTT.GetTree
Parameters
Results
[0]
name
status
child
name
status
Example #3
$o1->name = 'Tom';
$o1->status = 'Dad';
$o2->name = 'Wendy';
$o2->status = 'Daughter';
$o1->child = $o2;
return $o1;
com.mptt.MPTT.GetTree
Parameters
Results
name
status
child
name
status
So when I return the 3 examples int an arraycollection:
var ac:ArrayCollection = new ArrayCollection(result.result as Array);
and use that array collection as a dataprovider for a combobox
<mx:ComboBox x="204" y="107" id="cmbox" dataProvider="{ac}"
labelField="name"></mx:ComboBox>
Only example 1 and 2 return anything and that is only the first name,
none of the child names propagate the Combobox.
So my question with all of this, how (what format) should I return my
data from php to flex so I can add it (the data) to an arraycollection.
Thanks for all the help, this group rocks,
timgerr
--- In [email protected], "timgerr" <[EMAIL PROTECTED]> wrote:
>
> Hello all,
> I am working with nested arrayobjects and I cannot construct the
> needed data from my php/mysql backend.
>
> I am using nested sets
> (http://dev.mysql.com/tech-resources/articles/hierarchical-data.html),
> with left and right keys. I need to construct the data (in php) and
> pass it to flex (using a remote call). I need/want to get the data to
> flex and put it into an arraycollection. Has any one done this? If
> so, can you post some code? I have been banging my head on this for a
> long time and cannot get the data into the right format for an array
> collection.
>
> Thanks for the help,
> timgerr
>