Hey All,
I'm having an issue that I was hoping someone can help me out with.
I need to populate a datagrid based on XML being returned to Flex. The
structure of the XML is as follows:
"<root>
<lab id="2" title="Chemical Materials">
<assignment assignmentid="2" name="s2 s2" grade="B"/>
<assignment assignmentid="4" name="s1 s1" grade="C"/>
<assignment assignmentid="6" name="John Smith" grade="B"/>
</lab>
<lab id="8" title="BioChem">
<assignment assignmentid="3" name="s2 s2" grade="F"/>
<assignment assignmentid="5" name="John Smith" grade="D"/>
</lab>
</root>"
When this XML gets returned to Flex I need to throw it into a Datagrid for
diaplay. The catch is there can be any number of columns in the datagrid
becasue the assignments can be of different quantities.
Here is the code that I am using to make the grid:
"private function getGradebookSectionDb(event:ResultEvent):void{
var gradebookBySection:XMLList = event.result.lab;
var cols:Array=new Array;
for (var i:int=0;i<gradebookBySection.length();i++){
var col:DataGridColumn=new DataGridColumn();
col.headertext=gradebookbysection[[email protected]();
col.dataField=gradebookBySection[i].children()[email protected]();
cols.push(col);
gradebookDatagrid.columns=cols;
gradebookDatagrid.visible=true;
}"
When I do this, the columns get created from the XML very nicely with the
headers displaying correctly but there is no data showing up in the columns. I
would like to get one of the attribute values in each column but for some
reason nothing comes up. When I do a trace on the "col.datafield" I get the
right information coming back in the trace but nothing shows up in the column.
I would have just assigned the XML as a datapovider to the datagrid but as the
amount of assignments returned can change, I saw this as my only option.
Can anyone help me with this?
Thanks!