Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdvancedDataGrid does not displays object properties

I have following data:

var data: ArrayCollection = new ArrayCollection(
            [
                { name: "ProductA", user: {login: "loginA", email: "emailA"} },
                { name: "ProductB", user: {login: "loginB", email: "emailB"} },
                { name: "ProductC", user: {login: "loginC", email: "emailC"} }
            ]
        );

This array is a data provider for my AdvancedDataGrid:

<mx:AdvancedDataGrid dataProvider="{data}">
    <mx:columns>
        <mx:AdvancedDataGridColumn headerText="Product" width="55" dataField="name" /> 
        <mx:AdvancedDataGridColumn headerText="User" dataField="user.login" />
        <mx:AdvancedDataGridColumn headerText="Email" dataField="user.email" />
    </mx:columns>
</mx:AdvancedDataGrid>

The problem is - AdvancedDataGrid does not displays properties of nested User object, but the simple DataGrid does. What's wrong here ?

like image 553
AntonAL Avatar asked Feb 19 '10 19:02

AntonAL


2 Answers

You need to use a labelFunction or an itemRenderer. Here is an example of a labelFunction

<mx:AdvancedDataGridColumn headerText="User" labelFunction="getUserLogin" />

which calls

private function getUserLogin(item:Object, column:AdvancedDataGridColumn) {
  return item.user.login;
}

The item argument will be the data that your cell is receiving.

like image 119
Robusto Avatar answered Nov 04 '22 04:11

Robusto


DataGrid was patched to support complex paths but I don't think that AdvancedDataGrid was. More details: http://bugs.adobe.com/jira/browse/SDK-9801

You can use a labelFunction instead.

like image 21
James Ward Avatar answered Nov 04 '22 04:11

James Ward