I encountered this same thing before. The solution is to use a
labelfunction. 

Like this:

Here is the grid column.
<mx:DataGridColumn headerText="Port Country"
labelFunction="myLabelFunction" />


Here is the function which should reside inside the Script tag:

private function myLabelFunction(item:Object, col:DataGridColumn) : String
      {
        return item.userGroup.name;
      }

Give this a try. 

Jeremy Sanders
Cardinal Solutions Group.
[EMAIL PROTECTED]

--- In [email protected], "Niko Schmuck" <[EMAIL PROTECTED]>
wrote:
>
> 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