
Populate a DataGrid control 115
Populate a DataGrid control
In your application, you want the DataGrid control to display the titles of recent posts and
the dates they were posted.
1. In Source mode, enter the following dataProvider property (in bold) in the
<mx:DataGrid> tag:
<mx:DataGrid x="20" y="20" id="dgPosts" width="400"
dataProvider="{feedRequest.lastResult.rss.channel.item}">
You want the XML node named item to provide data to the DataGrid control. This node
is repeated in the XML, so it will be repeated in the DataGrid.
2. In the first <mx:DataGridColumn> tag, enter the following headerText and dataField
property values (in bold):
<mx:DataGridColumn headerText="Posts" dataField="title"/>
You want the first column in the DataGrid control to display the titles of the posts. You do
this by identifying the field in the XML that contains the title data, and then entering this
field as the value of the
dataField property. In the XML node specified in the
dataProvider property (item), the child node called title contains the information you
want.
3. In the second <mx:DataGridColumn> tag, enter the following headerText, dataField
and
width property values (in bold):
<mx:DataGridColumn headerText="Date" dataField="pubDate" width="150"/>
You want the second column in the DataGrid to display the dates of the posts. In this case,
the field that contains the data is called
pubDate.
4. Delete the third <mx:DataGridColumn> tag because you don’t need a third column.
Comentários a estes Manuais