如果在数据字段中找到某个单词,我正在尝试更改数据网格中行的字体颜色。 有没有一种简单的内联方法可以做到这一点?
谢谢
最佳答案
您可以重写DataGrid
的drawRowBackground方法,并检查它是否需要自定义背景。
如果是这样,请将新的背景颜色传递给此方法的 super
调用:
protected override function drawRowBackground(s:Sprite, rowIndex:int,
y:Number, height:Number, color:uint, dataIndex:int):void
{
if ((dataProvider[dataIndex] as String).indexOf(someWord) >= 0)
color = yourCustomColor;
super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
}
其中 someWord
是您要搜索的单词,yourCustomColor
是表示新背景颜色的 uint
,例如:
var yourCustomColor: uint = 0xff0000;
关于apache-flex - Datagrid FLEX 中的不同行样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6015445/