【问题标题】:Flex Advanced Datagrid Condition Row Background ColorFlex Advanced Datagrid 条件行背景颜色
【发布时间】:2009-07-03 09:34:25
【问题描述】:

我正在尝试为 Flex 3 中的高级数据网格控件设置行背景颜色。有谁知道这是否可以使用样式函数。目前我的样式函数如下所示:

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;     
         }      

但是背景颜色没有改变。

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

任何帮助将不胜感激。

问候卡尔

【问题讨论】:

    标签: apache-flex flex3 styles


    【解决方案1】:

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

    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);         
            }           
        }
    

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

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 2013-06-16
      • 2023-01-16
      • 2011-09-12
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多