• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1838
  • Last Modified:

Getting column names from arrayCollection

I wish to loop over an array collection and access all the elements (columns)

so the arrayCollection looks like


I need to loop over the rows and columns, but dont know the column names, any ideas.
  • 2
1 Solution
Try this:

It worked in AS2 and it wont work for bindable properties but it works for simple objects.

for (var key:String in object)
    data = object[key] ;

where object is your arraycollection item ie ac[0]
PluckaAuthor Commented:
Cool, I tried that but must have had something wrong.
I'm a novice at Flex, ActionScript, and object oriented programming in general.  I'm trying to have a multi-dimension array (arrayCollection) (2 dimension) and want to access the column data using the first dimension (row pointer) (which is a string) as variable to point to the other  columns in the array.  I currently have:
private function getArrayDataValue(currentArray:ArrayCollection,fieldLabel:String):String {
var key:String = fieldLabel;
var displayValue:String = currentArray[key].data;
return displayValue;
I am getting the following error on execution:
Error: Unknown Property: 'freightTerms'.
      at mx.collections::ListCollectionView/http://www.adobe.com/2006/actionscript/flash/proxy::getProperty()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:694]
      at com.olt.transportation.update::UpdateFullView/getArrayDataValue()[C:\adobeFlexTraining\_workspace\FlexBuilder\src\com\olt\transportation\update\UpdateFullView.mxml:55]
      at <anonymous>()[C:\adobeFlexTraining\_workspace\FlexBuilder\src\com\olt\transportation\update\UpdateFullView.mxml:70]

The code calling the function is:
<mx:Label id="freightTerms" text="{getArrayDataValue(updateTR,'freightTerms')}"/>

Any reasonable suggestion will be greatly appreciated.
An arrayCollection is not really a multidimetional array.  Its an array of Objects.

Also to access arrayCollection elements you must use


you cant do myArrayColelction[1]

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now