2 Replies Latest reply on Apr 5, 2010 8:42 PM by megharajdeepak

    How to add a new column to existing item of an arraycollection?

    megharajdeepak Level 1

      Hi there,

       

      I've an arraycollection, acLeaseContract, which has this structure:

       

      Capture.JPG

       

      these are the columns and their respective data that i receive from backend system. Now, I would like to add 2 more columns, after TenantName.

       

      I can loop through this arraycollection, create a object, add all those columns again to the new object and also add the new columns that i wish to add, and finally add this object to the arraycollection.

       

      for(i=0;i<acLeaseContract.length;i++){

       

           var o:Object = new Object();

           o.ContNo =acLeaseContract[i].ContNo;

           o.ContType = acLeaseContract[i].ContType ;

           o.EndDt = acLeaseContract[i].EndDt ;

           .

           .

           .

           .

           o.TenantName =acLeaseContract[i].TenantName ;

           o.MyNewColumn1="somevalue";

           o.MyNewColumn2="somevalue";

       

           acLeaseContract.addItemAt(o,i);

      }

       

      But I feel this is very tedious and time consuming, as we are re constructing the entire arraycollection again, just to add a couple of more columns.

       

      Is there a smart way to update the arraycollection with new entries, if yes can you pls tell me how can this be achieved?

       

      Thanks for you help....

       

      -Deepak