Flex 高级数据网格条件行背景颜色 [英] Flex Advanced Datagrid Condition Row Background Color

查看:24
本文介绍了Flex 高级数据网格条件行背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Flex 3 中的高级数据网格控件设置行背景颜色.有谁知道这是否可以使用样式函数.目前我的样式功能看起来像:

I am trying to set the row background color for the advanced data grid control in Flex 3. Does anyone know if this is possible using a style function. Currently my style function looks like:

public function myStyleFunc(data:Object, col:AdvancedDataGridColumn):Object 
         {
            if (data["status"] == "PRICING") 
                return {color:0xFF0000 , fontWeight:"bold" , backgroundColor:0xFF0000}; 


            // Return null if the Artist name does not match.
            return null;     
         }      

但是背景颜色没有改变.

However the background color does not change.

我在葡萄树上听说我可能需要重写一些方法来启用背景颜色属性.

I have heard on the grape vine that I may need to override some methods to enable the background color property.

任何帮助将不胜感激.

问候卡尔

推荐答案

我做过类似的事情,但在我的情况下,颜色也来自数据,但它会对你有所帮助.您必须覆盖 Datagrid 并覆盖 drawRowBackground 方法

I have done some thing like that but in my case color was also coming from data also but it will help you. You have to override the Datagrid and override drawRowBackground method

public class CustomDataGrid extends AdvancedDataGrid
    {   

        protected override function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void{
              var XMLdata:XML=rowNumberToData(dataIndex) as XML;               
              if(XMLdata!=null){          
                        if(XMLdata.attribute(Constants.col) != undefined && XMLdata.attribute(Constants.col) != ""){
                            color=XMLdata.attribute(Constants.col);         
                        }else{
                            color=0xFFFFFF;
                        }                            
              }               
              super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);         
        }           
    }

通过这个你可以从行中获取任何数据并根据它给出颜色.

By this you can get any data from the row and according to it give the color.

这篇关于Flex 高级数据网格条件行背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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