To use dataField, the properties must be top level properties of the
item object.

 

To access nested objects, you must use a labelFunction.

 

labelFunction automatically receives two arguments, a reference to the
item object that is creating the current row, and a reference to the
dataGridColumn object, so tht you can use a single labelFunction for
multiple columns.

 

Here is an example:

http://www.cflex.net/showFileDetails.cfm?ObjectID=258&Object=File&Channe
lID=1

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Niko Schmuck
Sent: Thursday, December 07, 2006 7:00 AM
To: [email protected]
Subject: [flexcoders] Dot notation to access objects inside a datagrid
column

 

Hi FlexCoders:

Coming from a Java background, I was surprised that the dot operator is
not working as I expected.

The array with the data structure and children is populated from the 
(Hibernate) data source at creationComplete time with:

ds.fill(users, "all.users", []);

The array collection is declared via:

<mx:ArrayCollection id="users" />

and then used inside the datagrid ...

<mx:DataGrid id="dgrid" dataProvider="{users}" editable="false">
<mx:columns>
<mx:DataGridColumn headerText="User ID" dataField="id"/>
<mx:DataGridColumn headerText="First Name" dataField="firstName"/>
<mx:DataGridColumn headerText="Last Name" dataField="lastName"/>
<mx:DataGridColumn headerText="Group" dataField="userGroup.name"/>
</mx:columns>
</mx:DataGrid>

Unfortunately the dot-access to the related user group name seems not to
work, there is just nothing being displayed. If dataField="userGroup"
then
there is [object UserGroup] displayed inside the datagrid column.

So how do you retrieve the properties of the related user group object?

Thanks for your help,
Niko

PS: The classes for value objects look very straight-forward:

// User.as
package com.example.flex
{

[Managed]
[RemoteClass(alias="com.example.flex.User")]

public class User
{

public var id:Number;
public var firstName:String = "";
public var lastName:String = "";
public var userGroup:UserGroup;

public function User() {
}

}
}

// UserGroup.as
package com.example.flex
{

[Managed]
[RemoteClass(alias="com.example.flex.UserGroup")]

public class UserGroup
{

public var id:Number;
public var name:String = "";

public function UserGroup() {
}

}
}

 

Reply via email to