在使用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单元测试以及集成测试的开源测试框架