• 【设为首页】
  • 【收藏闪客居】
当前位置:主页>Flex>文章内容
  • 按条件显示DataGrid/AdvancedDataGrid中行的背景颜色
  • 来源:l4cd.net 作者:l4cd.net 2008-10-11 【


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

下面是两种常用的应用..

一.跟据指定的字段数据,条件显示指定的行的指定背景色..
下面这个是根据成绩的字段.,低于60分即显示橙红色..
<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
      {
        var list:XMLList = new XMLList(dataProvider)
        if(dataIndex < list.length() && list[dataIndex].@result<60)color = 0xFF6600
        super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
      }
    ]]>
  </mx:Script>
</mx:DataGrid>


二.根据单双行显示隔行颜色..
<?xml version="1.0" encoding="utf-8"?>
<mx:DataGrid xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void
      {
        if(dataIndex%2==0)color = 0xcccccc
        super.drawRowBackground(s,rowIndex,y,height,color,dataIndex);
      }
    ]]>
  </mx:Script>
</mx:DataGrid>


相关MXML下载



上一篇:在windows下 让 FireFox 2.0 和 3.0 共存   下一篇:fluint: 具有图形界面的Flex单元测试以及集成测试的开源测试框架
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)