Q:

Populating a cell in a dataGrid with multiple values seperated by commas - Flex

I have an XML file with this data.
<resultSet> 
<MerchandiseAssortmentCategory>
                                <merchandiseAssortmentCategoryId>275</merchandiseAssortmentCategoryId>
                                <merchandiseAssortmentCategoryName>D21 Plywood</merchandiseAssortmentCategoryName>
                                <merchandiseSubordinateClasses>
                                                <merchandiseSubordinateClass>
                                                                <merchandiseSubordinateClassNumber>2</merchandiseSubordinateClassNumber>
                                                                <merchandiseSubordinateClassDescription>SHEATHING</merchandiseSubordinateClassDescription>
                                                </merchandiseSubordinateClass>
                                                <merchandiseSubordinateClass>
                                                                <merchandiseSubordinateClassNumber>3</merchandiseSubordinateClassNumber>
                                                                <merchandiseSubordinateClassDescription>WAFERBOARD</merchandiseSubordinateClassDescription>
                                                </merchandiseSubordinateClass>
                                                <merchandiseSubordinateClass>
                                                                <merchandiseSubordinateClassNumber>4</merchandiseSubordinateClassNumber>
                                                                <merchandiseSubordinateClassDescription>SANDED</merchandiseSubordinateClassDescription>
                                                </merchandiseSubordinateClass>
                                </merchandiseSubordinateClasses>
</MerchandiseAssortmentCategory>
</resultSet> 

I need to populate a data grid with the merchandiseAssortmentCategoryName and all its merchandiseSubordinateClassNumber(s) seperated with commas in the same row. 
the categoryList is which is the dataprovider for the dataGrid is defined as follows :
this.categoryList= evt.result.resultSet.MerchandiseAssortmentCategory;

and this is how the dataGrid is defined
<mx:DataGrid x="466" y="73" width="192" height="225" 
        dataProvider="{categoryList}" 
        verticalScrollPolicy="on" 
        id="categories"
        rowCount="10" enabled="true">
        <mx:columns>
            <mx:DataGridColumn headerText="Category name" dataField="merchandiseAssortmentCategoryName"/>
            <mx:DataGridColumn headerText="Subclasses" dataField="merchandiseSubordinateClasses.merchandiseSubordinateClass.merchandiseSubordinateClassNumber"/>

            </mx:columns>
    </mx:DataGrid>

When i run this, only the category name is filled. the subordinateclass number is just blank. Help out with this. Thanks

A:

You're going to have to write a labelFunction to return the comma separated list you want displayed in the column.  
Read these docs on creating a custom label function.  Here are some relevant details:
[Start Quote]
You can pass a label function to the List control to provide logic that determines the text that appears in the control. The label function must have the following signature:
labelFunction(item:Object):String

The item parameter passed in by the Label control contains the list item object. The function must return the string to display in the List control.
Note: Most subclasses of ListBase also take a labelFunction property with the signature described above. For the DataGrid and DataGridColumn controls, the method signature is labelFunction(item:Object, dataField:DataGridColumn):String, where item contains the DataGrid item object, and dataField specifies the DataGrid column.
....
<mx:Script><![CDATA[
    public function myLabelFunc(item:Object):String {
        return item.data + ", " + item.label; 
    }
]]></mx:Script>

[End Quote]
The item object parameter is the element of the dataProvider you want to generate a label for.
You can specify the labelFunction property on the class in question:
<mx:DataGridColumn labelFunction="myLabelFunc" />

You can also do the same thing with a custom itemRenderer.

