I've an arraycollection, acLeaseContract, which has this structure:
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.
var o:Object = new Object();
o.ContType = acLeaseContract[i].ContType ;
o.EndDt = acLeaseContract[i].EndDt ;
o.TenantName =acLeaseContract[i].TenantName ;
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....
Try using ObjectUtil.copy method. This will create a deep copy for your object like :
var tempArray:Array = ObjectUtil.copy(acLeaseContract.source) as Array;
acLeaseContract = new ArrayCollection(tempArray);
This will avoid your iteration to just copy your arrayCollection deeply.
Now when you watch acLeaseContract it will contain all dataStructure as Object. Now you are free to add any no of column to any node.
Hope this helps you.
thank you Vikash.... that helped me..........