如果您需要mx:DataGrid
可选择的,但也希望选择颜色不影响您的单元格/行的颜色,您可以使用这种方法:
扩展DataGrid
一个覆盖函数drawSelectionIndicator
并将函数的内容留空(您可能也对覆盖drawHighlightIndicator
函数感兴趣)
public class CustomRowColorDataGrid extends DataGrid
{
public function CustomRowColorDataGrid()
{
super();
}
override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void
{
//If you want a rectangle arround the selected row use call this method
//Rectangle(indicator,x,y,0xFF9900, 2,h) ;
}
override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void
{
Rectangle(indicator,x,y,highlight, 2,h) ;
}
private function Rectangle(indicator:Sprite, xx:int, yy:int,colorBorde:uint,grosor:int, h:int):void
{
var g:Graphics ;
var w:int ;
w = this.width - this.verticalScrollBar.width-1 ;
g = Sprite(indicator).graphics;
g.clear();
g.lineStyle(grosor,colorBorde) ;
g.drawRect(0,1,w-grosor,h-grosor) ;
indicator.x = xx;
indicator.y = yy;
}
}