Passing data to a DataGrid control
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData()">
<mx:Script>
import mx.collections.*;
private var DGArray:Array = [
{Artist:'A', Album:'AA', Price:11.99},
{Artist:'B', Album:'bb', Price:11.99}];
[Bindable]
public var initDG:ArrayCollection;
public function initData():void {
initDG=new ArrayCollection(DGArray);
}
</mx:Script>
<mx:DataGrid id="myGrid" width="350" height="200" dataProvider="{initDG}">
<mx:columns>
<mx:DataGridColumn dataField="Album" />
<mx:DataGridColumn dataField="Price" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
Related examples in the same category