Well, I have figured it out for myself.

One thing that you have access to in a DataGrid Item Renderer is the
actual data itself. You can coerce this data to a DataGridListData
object which then has access to the rowIndex and columnIndex
properties you have clicked.


--- In flexcoders@yahoogroups.com, "valdhor" <[EMAIL PROTECTED]> wrote:
>
> Here is my itemRenderer...
> 
> package customcomponents
> {
>       import flash.events.*;
>       import mx.controls.*;
>       import mx.controls.dataGridClasses.DataGridListData;
>       import mx.core.*;
> 
>       public class CellField extends LinkButton
>       {
>               public var fieldValue:String;
>               
>               public function CellField()
>               {
>                       super();
>                       addEventListener(MouseEvent.CLICK,
Application.application.cellClick);
>               }
>                       
>               override public function set data(value:Object):void
>               {
>                       if(value != null)
>                       {
>                               super.data = value;
>                                       
>                               fieldValue = 
> value[DataGridListData(listData).dataField];
>                               
>                               if (Number(fieldValue) == 0)
>                               {
>                                       label = "0";
>                                       enabled = false;
>                                       useHandCursor = false;
>                               }
>                               else
>                               {
>                                       label = fieldValue;
>                                       enabled = true;
>                                       useHandCursor = true;
>                                       setStyle("color", "#FF0000");
>                                       setStyle("textDecoration", "underline");
>                                       setStyle("textRollOverColor:", 
> "#0000CC");
>                               }
>                       }
>               }
>       }
> }
> 
> And here is how I am using it...
> 
> <mx:DataGridColumn id="ConfigChangesColumn"
> headerText="{newline}Config{newline}Changes" dataField="configchanges"
> width="60" sortable="false" itemRenderer="customcomponents.CellField"/>
> 
> and here is the cellclick function...
> 
> public function cellClick(event:Event):void
> {
>       Alert.show(String(event.currentTarget));
> }
> 
> So, now I need to know which cell was clicked.
> 
> Any help would be most appreciated.
> 
> 
> --- In flexcoders@yahoogroups.com, "Alex Harui" <aharui@> wrote:
> >
> > Where are you adding the event listener?  Can you use itemClick event?
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com
[mailto:[EMAIL PROTECTED] On
> > Behalf Of valdhor
> > Sent: Monday, December 17, 2007 12:59 PM
> > To: flexcoders@yahoogroups.com
> > Subject: [flexcoders] DataGrid LinkButton - How to get columnIndex and
> > rowIndex when linkButton is cli
> > 
> > 
> > 
> > Hi
> > 
> > I am a newbie with a problem - I have a datagrid with an itemRenderer.
> > The itemRenderer is an AS class that extends LinkButton and just
> > checks if the data is 0 or not. If it is 0 then disable the button.
> > Then it adds an event listener:
> > 
> > addEventListener(MouseEvent.CLICK, Application.application.cellClick);
> > 
> > This function gets called correctly but now I need to get the
> > columnIndex and rowIndex of the cell that the linkbutton was in. The
> > target and currentTarget are the same (The custom ItemRenderer class).
> > If I then try parentDocument, it returns the panel that holds the
> > datagrid. None of the panels or datagrids have ID's as they are
> > created on the fly based on a HTTPService lookup.
> > 
> > Can anyone tell me how to go about getting the columnIndex and
> > rowIndex of the clicked linkbutton?
> > 
> > Best Regards
> > 
> > Steve
> >
>


Reply via email to