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

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

问题描述

我想在Flex 3中设置高级数据网格控件的行背景颜色。有谁知道这是否可以使用样式函数。目前我的样式函数如下所示:
$ b $ pre $ public $ my code public function myStyleFunc(data:Object,col:AdvancedDataGridColumn):Object
{
if(data [status] ==PRICING)
return {color:0xFF0000,fontWeight:bold,backgroundColor:0xFF0000};


//如果艺术家名称不匹配,则返回null。
返回null;
}

但背景颜色不会改变。

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



任何帮助将不胜感激。



问候Karl

解决方案

在我的情况下,颜色也来自数据,但它会帮助你。
您必须重写Datagrid并重写drawRowBackground方法
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $>公共类CustomDataGrid扩展AdvancedDataGrid
{

protected override function drawRowBackground(s:Sprite,rowIndex:int,y:Number,height:Number,color:uint,dataIndex:int):void {
var XMLdata:XML = rowNumberToData(dataIndex )作为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);




$ b $ p
$ b $ p这样你就可以从行中获得任何数据,根据它给的颜色。


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.

Any help would be appreciated .

Regards Karl

解决方案

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高级Datagrid条件行背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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