I ran into similar issues with the DataGrid and multiple item renderers and the reuse of item renderers when scrolling. In order to access DataGrid item renderers I extended the DataGrid. My first thought was to use the indicesToIndex() followed by indexToItemRenderer(). Unfortunately these methods didn't do what I expected so I added the indicesToItemRenderer() method:
package com.whatever.controls
{
import mx.controls.DataGrid;
import mx.controls.listClasses.IListItemRenderer;
public class CustomDataGrid extends DataGrid
{
public function CustomDataGrid()
{
super();
}
public function indicesToItemRenderer(rowIndex:int, colIndex:int):IListItemRenderer
{
var firstItemIndex:int = verticalScrollPosition - offscreenExtraRowsTop;
if (rowIndex < firstItemIndex ||
rowIndex >= firstItemIndex + listItems.length
)
{
return null;
}
return listItems[rowIndex - firstItemIndex][colIndex];
}
}
To resolve the reused item renderers when scrolling issue, refer to this article:
http://www.adobe.com/devnet/flex/articles/itemrenderers_pt1.html
It boils down to overriding the data setter and storing properties in data. For example, I had one column using a CheckBox itemRenderer and another column using ComboBox. For both I listen for the change event and store selected, selectedIndex, etc in data whenever properties change and override the data setter to set those properties:
override public function set data(value:Object):void
{
if (value != null)
{
super.data = value;
if (data.hasOwnProperty('selected') && data.selected)
{
selected = data.selected;
}
else
{
selected = false;
}
}
}