AdvancedDataGrid does not display object properties

I have the 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 the 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> 

Problem - AdvancedDataGrid does not display the properties of a nested User object, but a simple DataGrid does. What is wrong here?

+6
flex flex3 advanceddatagrid
source share
2 answers

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

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

which causes

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

An element argument is the data that your cell receives.

+7
source share

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

Instead, you can use the labelFunction function.

+1
source share

All Articles