You need to use a labelFunction.

<mx:DataGridColumn headerText="X Pos" labelFunction="lfShowPOS"/>

 

private function lfShowPOS(item:Object, , column:DataGridColumn):void{

  var sLabel:String = ""

  var sHeaderText:String = column.headerText;   //you could probaly also use index, or dataField

  switch (sHeaderText)  {

    case "X Pos":

      sLabel = item.position.x;

      break;

    case "Y Pos":

      sLabel = item.position.y;

      break;                                       

    }

    return sLabel;
}

 

Tracy


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of zorelake
Sent: Thursday, July 06, 2006 5:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Showing data in Datagrid

 

Hi all! I've just started with Flex and I have some doubts I hope
you could solve.

I have a Datagrid filled with the result of a Java Method
(getRestaurants). This method returns a list of Restaurant objects
with the fields "name" and "adress".

<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Address" dataField="address"/>

I have no problems doing this, but I need to show another property
called "position". This property is an instance of a Position class,
whose properties are "x" and "y".

I mean:

Restaurant {
name: String;
address: String;
position: Position; // Contains x and y
}

In order to show "x" and "y" in the Datagrid, I'd need something
like this:

<mx:DataGridColumn headerText="X" dataField="position.x"/>

but it doesn´t work. I've tried in several ways, but with no results.
I've checked the field "position" and it contains the correct
values. So, I only need to show them!!.How could I do this?

I'd be very pleased if you could help me!
Thanks in advance!

P.S: Sorry for my English :)

__._,_.___

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





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to