

Ans:
ArrayCollection:
The ArrayCollection class is a wrapper class that exposes an Array as a collection that can be accessed and manipulated using the methods and properties of the ICollectionView or IList interfaces. Operations on a ArrayCollection instance modify the data source; for example, if you use the removeItemAt() method on an ArrayCollection, you remove the item from the underlying Array.
For example:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
private function gridinitialize():void {
data.dataProvider = [
{aName:'Bikrant', DOB:'01/01/1986',
City:'Delhi', State:'NewDelhi'},
{aName:'Brijesh', DOB:'15/07/1984',
City:'Noida', State:'Uttar Pradesh'},
{aName:'Gaurav', DOB:'27/06/1989',
City:'Mumbai', State:'Maharashtra'}
];
}
]]>
</fx:Script>
<s:Panel title="DataGrid Control Example" width="428" height="409">
<mx:DataGrid id="data"
initialize="gridinitialize()"
x="12" y="12"
borderColor="#000000"
borderStyle="solid"
chromeColor="#000000"
color="#90BB2A"
fontFamily="verdana"
fontGridFitType="pixel"
symbolColor="#FFFFFF"
textAlign="center"/>
</s:Panel>
</s:Application>
ListCollectionView:
The ListCollectionView class adds the properties and methods of the ICollectionView interface to an object that conforms to the IList interface. As a result, you can pass an object of this class to anything that requires an IList or ICollectionView.
This class also lets you use [ ] array notation to access the getItemAt() and setItemAt() methods. If you use code such as myListCollectionView[index] Flex calls the myListCollectionView object's getItemAt() or setItemAt() method.
For example:
<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600">
<s:Panel title="List dataProvider test" creationComplete="onCreate()"
paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:List id="list" width="100%" dataProvider="{filtered_stuff}"/>
<s:Button click="addItem()" label="Add item"/>
</s:Panel>
<fx:Script>
<![CDATA[
import mx.collections.ListCollectionView;
import mx.collections.ArrayCollection;
[Bindable] public var stuff:ArrayCollection;
[Bindable] public var filtered_stuff:ListCollectionView;
public function addItem():void {
trace("adding item", stuff.length);
stuff.addItem({label: stuff.length});
}
public function onCreate():void {
stuff = new ArrayCollection([{label: 0}]);
filtered_stuff = new ListCollectionView(stuff);
filtered_stuff.filterFunction = function(item:Object):Boolean {
return item.label > 0;
}
filtered_stuff.refresh();
}
]]>
</fx:Script>
</s:Application>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.