I'm building a DataGrid to display data similar to the following XML:
<foo>
<entities>
<entity>
<name>Jim</name>
<trend>
<quantity>10</quantity>
<quantity>20</quantity>
<quantity>30</quantity>
</trend>
</entity>
...
</entities>
</foo>
The idea is to have the grid display the name in one column and a small graphic (sparkline) in the second column based on the quantities. I have a sparkline component that needs an ArrayList as a dataProvider. My grid is set up thusly:
<!-- XML from dataservice transformed into XMLListCollection -->
<mx:XMLListCollection id="xmlcol" source="{xmlData.entities.entity}"/>
<mx:DataGrid id="thegrid" dataProvider="{xmlcol}">
<mx:columns>
<mx:DataGridColumn id="name" dataField="name" headerText="Name" />
<mx:DataGridColumn id="spark" dataField="trend.quantity" header="Trend">
<mx:itemRenderer>
<mx:Component>
<mycomponents:Sparkline dataProvider="?????????" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
What is the best way (or anyway!) to set the dataProvider for the Sparkline component to the array of quantities? Do I need the dataField in the enclosing DataGridColumn? Is my approach all wrong?
As always, thanks in advance for any help you can provide.
TB