Have you tried to use  labelFunction ? 

private function labelFanctionCountry(item:Object):String
{
   return item.port.country;
}
                ....
<mx:DataGridColumn headerText="Port Country" 
labelFunction="labelFanctionCountry"/>


Irina

--- In [email protected], "laidezmon" <[EMAIL PROTECTED]> wrote:
>
> OK here is what i am trying to do.
> 
> I have a grid component, and I wanted to display on the grid, a list
> of ship objects. Think of this like a cruise liner.
> 
> I am retrieving these objects from a java/hybernate/spring adapter
> using remote object, and it works ok. I get back an arrayCollection,
> then I build a new array, populatate it with Actionscript ship
> objects, which has an embedded port object.
> 
> Ship has attributes like Name, id, comments etc. And it has an
> embedded homeport object also.
> 
> The port, has name, country and comments too.
> 
> I can get the object to come back, and its being built correctly. I
> have ship objects and each one has its own port object, I see in the
> debugger the objects and thier embedded objects and the embedded
> object values. So I know the constructor is working fine. Here is 
the
> problem.
> 
> I set the dataprovider attribute to match the array of completed
> ships, and I can get the grid, to display all the ship data, but not
> the port data.
> 
> So Here is my code:
> 
> <mx:DataGrid id="ShipListDataGrid" width="978" height="190"
> dataProvider="{initDG}" creationComplete="loadAllShips()"
> selectedIndex="0" >
> <mx:columns>
> <mx:DataGridColumn headerText="Name" dataField="name"/>
> <mx:DataGridColumn headerText="Class" dataField="clazz"/>
> <mx:DataGridColumn headerText="Comments" dataField="comments"/>
> <mx:DataGridColumn headerText="Port Country" 
dataField="port.country" />
> </mx:columns>
> </mx:DataGrid>
> 
> Now the colums name, clazz, comments all work perfectly, as they are
> attributes of ship. However, port.country does not work, it just 
shows
> a blank column, even though that is the correct notation to get to
> that data field, for the attribute of that ships port home country.
> Its just a string, so for the port called miami, the country 
is "USA".
> This does not display.
> 
> However if I remove port.country, and only put in port, then it 
shows
> that whats in that column displays as Object : Port.
> 
> So it seems that the grid knows theres an object in there. But not
> what to do with it?
> 
> I have created a masterViewList and a masterDetails component, and 
the
> viewList is the grid, and the details is the details section of the
> ship. So there it shows a form, and the form shows all the details 
of
> the ship selected in the list above. Heres the interesting thing.
> using a label field, I can change the selected list item on the 
grid,
> and show the ship.port.country in a label on the bottom, so it can
> transverse the ship object, but just not seemingly in the grid.
> 
> What can I do? Why does it work with a label field, and not in the
> grid? Why will the grid not show an embedded string attribute for an
> embedded object, but a label or text box will? What am I doing 
wrong?
> 
> 
> At the prompting of someone from the Flex Developer forums on adobes
> site, I implemented this also. 
> 
> On the column I put this as the datafield: (instead of the above
> port.country, or port)
> 
> <mx:DataGridColumn headerText="Port Country"
> dataField="{calcPortCountry}" />
> 
> 
> And created this function:
> 
> private function calcPortCountry(item:Object, 
col:DataGridColumn):String
>       {
>               return item.port.country;
>       }
> 
> But this also gets me the same result. Nothing inside the grid 
column.
> All the tutorials seem to be for passing simple objects which only
> contain simple attributes, strings ints, and stuff like that. 
Nothing
> with embedded objects. This is a ship object, which has an embedded
> port object inside it. I have tried debugging this new function, 
and I
> cannot even get into the function above to see whats being passed.
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to