dataprovider for datagrid

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”; layout=”vertical” viewSourceURL=”../src/Layout02.mxml”>
private function myLabelFunc(item:Object, dataField:DataGridColumn):String
var p:String = item.Price? item.Price: “N/A”;
return item.Year+” / ” +p;
<mx:ArrayCollection id=”dgPD”>
<mx:Object Artist1=”Pavement” Album1=”Slanted and Enchanted” Price1=”11.99″ Year=”2003″/>
<mx:Object Artist=”Finches” Album=”Daniel’s Song” Price2=”11.99″ Year=”2007″/>
<mx:Object Artist=”Pavarotti” Album=”Twilight” Price=”11.99″ Year=”1999″/>
<mx:Object Artist=”Other” Album=”Other” Price=”5.99″ Year=”2002″/>

<mx:Label text=”Data matter!”/>
<mx:DataGrid id=”myDG” width=”400″ rowCount=”10″ dataProvider=”{dgPD}”>
<mx:DataGridColumn headerText=”ARTIST” dataField=”Artist”/>
<mx:DataGridColumn headerText=”ALBUM” dataField=”Album”/>
<mx:DataGridColumn headerText=”YEAR &amp; PRICE” labelFunction=”myLabelFunc”/>
<!–<mx:DataGridColumn headerText=”PRICE” dataField=”Price”/>–>



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: