I'm about to pull my hair out trying to determine exactly how to add
items deep into an arrayCollection.  Below is some sample code (with
irrelevant code removed for brevity) in which I'm trying to add a link
name to a list of links inside of XML that I've pulled via HTTPService. 
How exactly, can I take the selectedItem from both the customer datagrid
and the link datagrid, and essentially push the linkname into the link
list under that specific customer?  Granted, I'm new to flex and OOP,
but I'm really stumped here.

TIA....

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" initialize="custList.send(),linkList.send()">
     <mx:Script>
         <![CDATA[
             [Bindable] private var customerData:ArrayCollection;
             [Bindable] private var linkData:ArrayCollection;

             private function
resultHandler(event:ResultEvent,type:String):void{
                 switch( type ){
                     case 'cust':
                         customerData=event.result.customers.customer as
ArrayCollection;
                         break;
                     case 'createCustLink':
                         ????
                         break;
                     case 'link':
                         linkData=event.result.links.link as
ArrayCollection
                         break;
                 }
             }
         ]]>
     </mx:Script>
     <mx:HTTPService id="custList"
url="https://localhost/flexOut.cgi?data=custList";
             result="resultHandler(event,'cust')"/>
     <mx:HTTPService id="custLinkAssign"
url="https://localhost/flexIn.cgi?input=custLinkAssign";
             result="resultHandler(event,'createCustLink')"/>
     <mx:HTTPService id="linkList"
url="https://localhost/flexOut.cgi?data=linkList";
             result="resultHandler(event,'link')"/>
     <mx:Panel x="10" y="10" width="701" height="379" layout="absolute"
title="Customers">
         <mx:DataGrid dataProvider="{customerData}" x="10" id="custs"
height="86" width="435.5" editable="false" y="10">
             <mx:columns>
                 <mx:DataGridColumn dataField="custName"
headerText="Name" width="60"/>
             </mx:columns>
         </mx:DataGrid>
         <mx:Text x="10" y="104" text="Links" fontWeight="bold"/>
         <mx:List x="10" y="126" width="210" height="203"
id="custsAssignLink" dataProvider="{custs.selectedItem.links.name}" />
     </mx:Panel>
     <mx:Panel x="10" y="397" width="315" height="288" layout="vertical"
title="Links">
         <mx:DataGrid dataProvider="{linkData}" id="links" width="295"
height="113">
             <mx:columns>
                 <mx:DataGridColumn headerText="Name" dataField="name"/>
             </mx:columns>
         </mx:DataGrid>
     <mx:Button  label="assign" click="custLinkAssign.send()"/>
</mx:Application>


Sample Data:
Customer Data-
<?xml version="1.0"?>
<customers>
<customer>
<custId>559</custId>
<custName>Customer1</custName>
<links>
<name>Link1</name>
<name>Link2</name>
</links>
</customer>
<customer>
<custId>32</custId>
<custName>Customer2</custName>
<links>
<name>Link3</name>
</links>
</customer>
</customers>

Link Data-
<?xml version="1.0"?>
<links>
<link>
<id>6</id>
<url>http://....</url>
<name>Link1</name>
</link>
<link>
<id>7</id>
<url>http://....</url>
<name>Link2</name>
</link>
<link>
<id>9</id>
<url>http://....</url>
<name>Link3</name>
</link>
<link>
<id>8</id>
<url>http://....</url>
<name>Link4</name>
</link>
</links>

Reply via email to