I am trying to display a list of items in a datagrid from an XMLList.
<Series no="1">
<file>
<filenum>1</epnum>
<prodnum>4V01</prodnum>
<title>Series #1 - File #1</title>
</file>
<file>
<filenum>2</epnum>
<prodnum>4V02</prodnum>
<title>Series #1 - File #2</title>
</file>
</Series>
<Series no="2">
<file>
<filenum>1</epnum>
<prodnum>4V01</prodnum>
<title>Series #2 - File #1</title>
</file>
<file>
<filenum>2</epnum>
<prodnum>4V02</prodnum>
<title>Series #2 - File #2</title>
</file>
</Series>
My current code allows me to retrieve every Series into an XMLList and then i have a nesteddatagrid class that allows me to do things like.
<classes:NestedDataGrid width="100%" height="100%" id="gridFiles" dataProvider="{filesList}" >
<classes:columns>
<mx:DataGridColumn headerText="Season" dataField="@no" width="60"/>
<mx:DataGridColumn headerText="Episode" dataField="file.filenum" width="60"/>
<mx:DataGridColumn headerText="Title" dataField="file.title"/>
</classes:columns>
</classes:NestedDataGrid>
However this displays the datagrid with two rows, the first row has 1 in the Series column and then the two files crammed into the second cell in the same row. The second row is the same but has the number 2 in the Series column and the two series #2 files crammed into the cell next to it.
If i do not use the nested data class i can pull the files using Series.file instead and all 4 of the files list correctly, however i do not get the Series number for each...
With the current structure of the xml, it's easier to represent it with a two column grid - first column being the series number, and second column being another 2 or 3 column DataGrid that displays file details. But if you don't wanna change the structure, the following code is what you need. Note that since
dataField
property is not set, you have to specify asortCompareFunction
for sorting the grid based on series number - otherwise it might throw exceptions while trying to sort.UPDATE: