数据网格 FLEX 中的不同行样式 [英] Different row styling in datagrid FLEX

查看:24
本文介绍了数据网格 FLEX 中的不同行样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在数据字段中找到某个单词,我正在尝试更改数据网格中一行的字体颜色.有没有一种简单的内联方式来做到这一点?

I'm trying to change the font color of a row in a datagrid if a certain word is found in a datafield. Is there a simple, inline way to do this?

谢谢

推荐答案

您可以覆盖您的 DataGrid 的 drawRowBackground 方法,并检查它是否需要自定义背景.
如果是,则将新的背景颜色传递给此方法的 super 调用:

You can override your DataGrid's drawRowBackground method, and check whether it needs custom background or not.
If so, pass the new background color to the super call of this method:

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,例如:

where someWord is the word you are searching for, and yourCustomColor is the uint representing the new background color, eg:

var yourCustomColor: uint = 0xff0000;

这篇关于数据网格 FLEX 中的不同行样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆