It is trivial to write a function to do what you want...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical" creationComplete="onCreationComplete()">
     <mx:Script>
         <![CDATA[
             import mx.collections.ArrayCollection;

             private var firstArray:Array = [1,2,3,4,5,6,7,8,9,10];
             private var secondArray:Array =
["one","two","three","four","five","six","seven","eight","nine","ten"];
             private var mergedArray:Array = new Array();

             private function onCreationComplete():void
             {
                 if(firstArray.length > 0 && firstArray.length ==
secondArray.length)
                 {
                     for(var i:int = 0 ; i < firstArray.length ; i++)
                     {
                         var tempObject:Object = new Object();
                         tempObject.item1 = firstArray[i];
                         tempObject.item2 = secondArray[i];
                         mergedArray[i] = tempObject;
                     }
                 }
                 datagrid.dataProvider = new
ArrayCollection(mergedArray);
                 datagrid.rowCount = datagrid.dataProvider.length;
             }
         ]]>
     </mx:Script>
     <mx:DataGrid id="datagrid"/>
</mx:Application>

--- In flexcoders@yahoogroups.com, Venkat M <venkat_yum@...> wrote:
>
> Hi Group,
>
> I have a basic question on arraycollections. Please assist.
>
> I have an array collection A populated with values
{1,2,3,4,5,6,7,8,9,10}
> Also I have an arraycollection B populated with values
{one,two,three,four,five,six,seven,eight,nine,ten}
>
> Given this data, How do I present this in a datagrid? Can I map at a
column level to an array collection?
> (Or)
> Can we make an arraycollection C, that has the values of
arraycollection A and arraycollection B paired up and then just bind to
datagrid. If so, please help me how to fabricate arraycollection C.
>                (Or)
> Any other ideas, please comment.
>
> Thanks in advance.
>
> Best Regards,
> Venkat.
>

Reply via email to