I recently posted a solution about the DataGrid in Flex 2 not highlighting rows correctly after certain events (specifically double-clicking a row). You can read that post here.
I wanted to simply update the code sample that I gave for the overridden drawRowBackground() method. The code I had before was from Flex 3 and introduced a bug that I (for the life of me) couldn’t find. So, I re-wrote it much more simply and this time it takes full advantage of the super class’s implementation rather than using Flex 3′s source. Here you go:
override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
var rowColor:uint = color;
if( this.selectedIndices.indexOf(rowIndex) != -1 )
rowColor = getStyle("selectionColor");
super.drawRowBackground(s, rowIndex, y, height, rowColor, dataIndex);
You can see, I’m simply overriding the color which is all I wanted to do in the first place. I don’t know why the best solutions always come after you leave and revisit the code but so be it.