I had to go one more level "up" and grab the 
event.mouseTarget.parent to get it to work as a generic renderer, 
and then call listData off of that guy, but your code got me 98% of 
the way there (I'm using Beta3, which may be why I had to change 
some things). Thanks

--- In [email protected], "Deepa Subramaniam" 
<[EMAIL PROTECTED]> wrote:
>
> Hi -
> 
>  
> 
> So the mouseTarget property is a reference to the 
DataGridItemRenderer
> which the context menu opened upon. You can access the listData 
property
> off of a DataGridItemRenderer to then access rowIndex and 
columnIndex
> and whatever other goodies you'd like. Check out my example below.
> 
>  
> 
> Cheers,
> 
> Deepa
> 
>  
> 
>  
> 
> <?xml version="1.0"?>
> 
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> creationComplete="initComp();">
> 
>  
> 
> <mx:Script>
> 
> <![CDATA[
> 
>    import flash.ui.*;
> 
>    import flash.events.*;
> 
>    import mx.controls.dataGridClasses.*;
> 
>  
> 
>     private var m:ContextMenu;
> 
>  
> 
>     private function initComp():void
> 
>     {
> 
>         myDataGrid.dataProvider =
> 
>          [
> 
>            { Artist:'Pavement', Album:'Slanted and Enchanted',
> Price:11.99, Rating:'Excellent' },
> 
>            { Artist:'Pavement', Album:'Crooked Rain, Crooked Rain',
> Price:10.99, Rating:'Excellent' },
> 
>            { Artist:'Pavement', Album:'Wowee Zowee', Price:12.99,
> Rating:'Excellent' },
> 
>            { Artist:'Pavement', Album:'Brighten the Corners',
> Price:11.99, Rating:'Good' },
> 
>            { Artist:'Pavement', Album:'Terror Twilight', 
Price:11.99,
> Rating:'Good' },
> 
>            { Artist:'Other', Album:'Other', Price:5.99, 
Rating:'Bad' }
> 
>          ];
> 
>  
> 
>             createContextMenu();
> 
>  
> 
>             myDataGrid.contextMenu = m;
> 
>  
> 
>     }
> 
>     
> 
>     private function createContextMenu():void
> 
>     {
> 
>                 m = new ContextMenu();
> 
>                 m.addEventListener("menuSelect", 
menuSelectHandler);
> 
>                 m.hideBuiltInItems();
> 
>                 var customItemsArr:Array = new Array();
> 
>                 var buy:ContextMenuItem = new ContextMenuItem
("Buy");
> 
>                 buy.addEventListener("menuItemSelect", buyHandler);
> 
>                 var rate:ContextMenuItem = new ContextMenuItem
("Change
> Rating");
> 
>                 rate.addEventListener("menuItemSelect", 
rateHandler);
> 
>                 customItemsArr.push(buy);
> 
>                 customItemsArr.push(rate);
> 
>                 m.customItems = customItemsArr;
> 
>     }
> 
>     
> 
>     private function buyHandler(e:ContextMenuEvent):void
> 
>     {
> 
>                 //..blah
> 
>     }
> 
>     
> 
>     private function rateHandler(e:ContextMenuEvent):void
> 
>     {
> 
>                 //..blah
> 
>     }
> 
>     
> 
>     private function menuSelectHandler(e:ContextMenuEvent):void
> 
>     {
> 
>                 var renderer:DataGridItemRenderer =
> DataGridItemRenderer(e.mouseTarget);
> 
>                 trace("rowIndex: " + renderer.listData.rowIndex);
> 
>                 trace("columnIndex: " +
> DataGridListData(renderer.listData).columnIndex);
> 
>     }
> 
>  
> 
>     
> 
> ]]>
> 
> </mx:Script>
> 
>  
> 
> <mx:DataGrid id="myDataGrid"/>
> 
>  
> 
> </mx:Application>
> 
> ________________________________
> 
> From: [email protected] 
[mailto:[EMAIL PROTECTED] On
> Behalf Of djbrown_rotonews
> Sent: Wednesday, June 14, 2006 9:09 AM
> To: [email protected]
> Subject: [flexcoders] ContextMenu and DataGrid question
> 
>  
> 
> I'm trying to set up a ContextMenu inside a DataGrid that has 
> knowledge of where in the grid the right click occured. 
> 
> All I'm able to see via the ContextMenuEvent is the mouseTarget 
that 
> knows about the underlying text in the cell. I'm needing something 
> similiar to rowIndex and columnIndex that ListEvent provides 
(allowing 
> me subsequent access to listData etc..)
> 
> Any examples/tips would be appreciated.
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
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/

<*> 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