dataprovider for datagrid

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”vertical” viewSourceURL=”../src/Layout02.mxml”>
<mx:Script>
<![CDATA[
private function myLabelFunc(item:Object, dataField:DataGridColumn):String
{
var p:String = item.Price? item.Price: “N/A”;
return item.Year+” / ” +p;
}
]]>
</mx:Script>
<mx:ArrayCollection id=”dgPD”>
<mx:source>
<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:source>
</mx:ArrayCollection>

<mx:VBox>
<mx:Label text=”Data matter!”/>
<mx:DataGrid id=”myDG” width=”400″ rowCount=”10″ dataProvider=”{dgPD}”>
<mx:columns>
<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”/>–>
</mx:columns>
</mx:DataGrid>
</mx:VBox>

</mx:Application>

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: