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?
Solved! Go to Solution.
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;
}
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;
}
Robert,
The datagrid doesn't have the itemRollOver event, but list does....is that what you are referring to?
Thanks,
Glen
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;
}