Robert Bak – Notes

Some programming tips – updated sometimes

Snippet- DataGrid labelField upgrade – complexFieldNameComponents

When displaying data in a DataGrid you can now reach into the inner structure of the data item while using the dataField property.

Let’s say your data is:

<employee>
    <name>Maurice Smith</name>
    <phone>555-219-2012</phone>
    <email>maurice@fictitious.com</email>
    <active>false</active>
    <description>
        <short>short description </short>
    </description>
</employee>
<employee>
    <name>Mary Jones</name>
    <phone>555-219-2000</phone>
    <email>mjones@fictitious.com</email>
    <active>true</active>
    <description>
        <short>short description </short>
    </description>
</employee>

If your data has nested fields, like the short one above you can use simple dataField to reach for them, like this:

<mx:DataGrid dataProvider="{employees}">
    <mx:columns>
        <mx:DataGridColumn dataField="description.short" headerText="Description"/>
    </mx:columns>
</mx:DataGrid>

I’m almost sure this wasn’t possible the last time I’ve tried this with some previous version of Flex SDK.

2 thoughts on “Snippet- DataGrid labelField upgrade – complexFieldNameComponents

Leave a Reply

Your email address will not be published. Required fields are marked *