Apache flex 如何将不同的列设置为在DataGridColumns上具有AlternatingItemColor?
在DataGrid上,设置AlternatingItemColor将颜色方案应用于该网格的所有列。我正在寻找一种为每列定义不同交替颜色的方法。有什么方法可以做到这一点吗?看看这个:我希望这对你有帮助;)Apache flex 如何将不同的列设置为在DataGridColumns上具有AlternatingItemColor?,apache-flex,Apache Flex,在DataGrid上,设置AlternatingItemColor将颜色方案应用于该网格的所有列。我正在寻找一种为每列定义不同交替颜色的方法。有什么方法可以做到这一点吗?看看这个:我希望这对你有帮助;) 公共类BlocksTable扩展了DataGrid { 公共静态常量有效颜色:uint=0xDBAB21; 公共静态常量无效\u颜色:uint=0xC7403E; 公共职能部门 { 超级(); } 重写受保护的函数drawRowBackground(s:Sprite,rowIndex:int,y
公共类BlocksTable扩展了DataGrid
{
公共静态常量有效颜色:uint=0xDBAB21;
公共静态常量无效\u颜色:uint=0xC7403E;
公共职能部门
{
超级();
}
重写受保护的函数drawRowBackground(s:Sprite,rowIndex:int,y:Number,height:Number,color:uint,dataIndex:int):void
{
var contentHolder:ListBaseContentHolder=ListBaseContentHolder(s.parent);
背景:形状;
if(行索引
public class BlocksTable extends DataGrid
{
public static const VALID_COLOR:uint = 0xDBAB21;
public static const INVALID_COLOR:uint = 0xC7403E;
public function BlocksTable()
{
super();
}
override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
{
var contentHolder:ListBaseContentHolder = ListBaseContentHolder(s.parent);
var background:Shape;
if (rowIndex < s.numChildren)
{
background = Shape(s.getChildAt(rowIndex));
}
else
{
background = new FlexShape();
background.name = "background";
s.addChild(background);
}
background.y = y;
// Height is usually as tall is the items in the row, but not if
// it would extend below the bottom of listContent
var height:Number = Math.min(height,
contentHolder.height -
y);
var g:Graphics = background.graphics;
g.clear();
var fillColor:uint;
if(dataIndex < this.dataProvider.length)
{
if(this.dataProvider.getItemAt(dataIndex).IS_VALID)
{
fillColor = VALID_COLOR;
}
else
{
fillColor = INVALID_COLOR;
}
}
else
{
fillColor = color;
}
g.beginFill(fillColor, getStyle("backgroundAlpha"));
g.drawRect(0, 0, contentHolder.width, height);
g.endFill();
}
}