Using an ArrayCollection to feed the DataGrid's dataProvider
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.collections.ArrayCollection;
[Bindable]
public var myAC:ArrayCollection = new ArrayCollection([
{name:"A", email:"a@domain.com"},
{name:"B", email:"b@domain.com"},
{name:"C", email:"c@domain.com"}
]);
</mx:Script>
<mx:DataGrid id="dg"
width="500"
height="150"
dataProvider="{myAC}">
<mx:columns>
<mx:DataGridColumn dataField="name"
headerText="Contact Name"
width="300" />
<mx:DataGridColumn dataField="email"
headerText="E-Mail"
width="200" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
Related examples in the same category