Reputation: 8880
Here I i'm trying to parsing a XML in like below:
<?xml version="1.0" encoding="utf-8" ?>
<spearkerslist>
<speakers langid="afb" countryid="SA">200000</speakers>
<speakers langid="acw" countryid="SA">6000000</speakers>
<speakers langid="ars" countryid="SA">8000000</speakers>
<speakers langid="arb" countryid="SA">206000000</speakers>
</spearkerslist>
By this code I'm able to parse parameters langid and countryid, but I'm not able to parse the actual values 200000, 6000000,... into the data grid. Is there a way to access this with out changing the generated XML.
<mx:Script>
[Bindable]
private var languagelist:XML = new XML();
</mx:Script>
<mx:DataGrid dataProvider="{languagelist.speakers}">
<mx:columns>
<mx:DataGridColumn id="populationCol" dataField="speakers" headerText="Speakers" />
<mx:DataGridColumn id="countryID" dataField="@countryid" headerText="Country Id" />
<mx:DataGridColumn id="LangID" dataField="@langid" headerText="Language Id" />
</mx:columns>
</mx:DataGrid>
Upvotes: 2
Views: 520
Reputation: 13620
Just a FYI for anyone facing similar problem.You can also specify dataField="*" to achieve the same result.
<mx:DataGridColumn id="populationCol" headerText="Speakers" dataField="*"/>
Upvotes: 0
Reputation: 59451
Try it without dataField
:
<mx:DataGridColumn id="populationCol" headerText="Speakers" />
If this doesn't work, use labelFunction
<mx:DataGridColumn id="populationCol" headerText="Speakers"
labelFunction="dgLabelFunction"/>
Define it as:
public function dgLabelFunction(item:Object, col:DataGridColumn):String
{
return item.text().toString();
}
Upvotes: 2