Flex DataGrid行自定义颜色

本文介绍了一种在Flex开发中使用ActionScript自定义AdvancedDataGrid行背景颜色的方法。通过检查数据项的不同属性来改变显示行的颜色,实现错误消息、不同状态的视觉区分。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址:http://blog.youkuaiyun.com/i_chenjiahui/article/details/22393821

以前在Flex开发中用到了表格要自定义行颜色的情况。

/**
 * ActionScript file 
 * @author chenjiahui
 */ 
package com.xxx.dm.module.jsjhcNew
{
 import flash.display.Sprite;
 
 import mx.controls.AdvancedDataGrid;
 
 public class RowColorAdvancedDataGrid extends AdvancedDataGrid
 {
  public function RowColorAdvancedDataGrid()
  {
   super();
  }
  override protected function drawRowBackground(
   s:Sprite, rowIndex:int, y:Number, height:Number, 
   color:uint, dataIndex:int):void
  {
   var item:Object;
   if(dataIndex <dataProvider.length)
   {
    item = dataProvider[dataIndex];
    if(item.error_msg != null && item.error_msg != ''){
     color = 0xffcccc;
    }else if(item.less_count>0){
     color = 0xffe3e3;
    }else if(item.error_count>0){
     color = 0xffe3e3;
    }else if(item.more_count>0){
     color = 0xffe3e3;
    }else if(item.redundant_count>0){
     color = 0xf4ed73;
    }else if(item.barbarism_count>0){
     color = 0xf4ed73;
    }
   }
   
   super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
  }
 }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值