Flex datagrid/advancedatagrid按条件显示行的背景颜色

在使用DataGrid/AdvancedDataGrid我们有时候会需要以指定的条件显示行的背景色..达到突出显示的效果..
下面是两种常用的应用..


一.跟据指定的字段数据,条件显示指定的行的指定背景色..
下面这个是根据成绩的字段.,低于60分即显示橙红色..

 

[c-sharp]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">  
  3.     <mx:Script>  
  4.         <!--[CDATA[  
  5.             override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void  
  6.             {  
  7.                 var list:XMLList = new XMLList(dataProvider)  
  8.                 if(dataIndex < list.length() && list[dataIndex].@result<60)color = 0xFF6600  
  9.                 super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);  
  10.             }  
  11.         ]]-->  
  12.     </mx:Script>  
  13. </mx:DataGrid>  

 

 

二.根据单双行显示隔行颜色..

 

[c-sharp]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">  
  3.     <mx:Script>  
  4.         <!--[CDATA[  
  5.             override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void  
  6.             {  
  7.                 if(dataIndex%2==0)color = 0xcccccc  
  8.                 super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);  
  9.             }  
  10.         ]]-->  
  11.     </mx:Script>  
  12. </mx:DataGrid>  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值