Select to view content in your preferred language

DataGrid MouseOver

1748
3
Jump to solution
07-28-2014 11:35 AM
GlenReid
Deactivated User

I have a DataGrid that displays some information.  I'm trying to use a mouseOver event to get some information from the grid:

<s:DataGrid id="indexGrid" width="335" height="162" top="4" dataProvider="{indexList}"

  mouseOver="indexGrid_mouseOverHandler(event)" mouseOut="indexGrid_mouseOutHandler(event)">

  <s:columns>

    <s:ArrayList>

      <s:GridColumn headerText="Region" width="175" dataField="REGION"/>

      <s:GridColumn headerText="Category" width="75" dataField="CATEGORY"/>

      <s:GridColumn headerText="Index" width="80" labelFunction="formatIndex" dataField="RSI"/>

    </s:ArrayList>

  </s:columns>

</s:DataGrid>

In my event handler, I can get the value of a column, but only with a hardcoded row:

private function indexGrid_mouseOverHandler(event:MouseEvent):void {

  trace (event.currentTarget.dataProvider.getItemAt(0).REGION);

  trace (event.currentTarget.dataProvider.getItemAt(0).RSI);

  trace (event.currentTarget.dataProvider.getItemAt(1).REGION);

  trace (event.currentTarget.dataProvider.getItemAt(1).RSI);

}

Anyone know how to get the index of the datagrid row?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Glen,

  Sorry about that. Use gridRollOver and GridRollOut events and event.itemRenderer.data

and you need to check if the itemRenderer exists

if(!event.itemRenderer || !event.itemRenderer.data){

     return;

}

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Glen,

Listen to the itemRollOver event instead of mouseOver and the event has a rowIndex property

private function onItemRollOver(event:ListEvent):void

{

    var rowIndex:int = event.rowIndex;

}

0 Kudos
GlenReid
Deactivated User

Robert,

The datagrid doesn't have the itemRollOver event, but list does....is that what you are referring to?

Thanks,

Glen

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Glen,

  Sorry about that. Use gridRollOver and GridRollOut events and event.itemRenderer.data

and you need to check if the itemRenderer exists

if(!event.itemRenderer || !event.itemRenderer.data){

     return;

}

0 Kudos