基于IF语句在Flex中突出显示DataGrid行 [英] Highlighting a DataGrid row in Flex based on an IF Statement

查看:205
本文介绍了基于IF语句在Flex中突出显示DataGrid行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一系列的DataGrids会定期从查询中提取数据。如果该行的一列中的指定值高于某个阈值,我想要突出显示整行。所以我需要能够解析DataGrid中的每一行,并突出显示具有高于100的特定值的任何行。 DataGrids中的数据量会有所不同,并且不能保证会有时间。



谢谢

 '覆盖保护函数updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void 
{
super.updateDisplayList(unscaledWidth,unscaledHeight);
var g:Graphics = graphics;
g.clear();
var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);
// var rowtotal:int = new int(dp [0] .length);
if(grid1.isItemSelected(data)|| grid1.isItemHighlighted(data))
return;
if(data [DataGridListData(listData).dataField] ==NJ)
{
g.beginFill(0xCC0033);
g.drawRect(0,0,unscaledWidth,unscaledHeight);
g.endFill();


$ / code $ / pre

解决方案

你必须使用一个Itemrenderer来实现这一点。在itemrenderer setdata方法中,您可以编写列的条件,将行的背景颜色更改为所需的颜色。


I have a series of DataGrids which will pull data in from a query regularly. I want to highlight an entire row if a specified value in one column of that row is above a certain threshold. So I need to be able to parse through every row in a DataGrid and highlight any row that has a specific value above "100" say. The amount of data in the DataGrids is going to vary and there's no guarantee there will be any at times.

Thanks

 'override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
    {
        super.updateDisplayList(unscaledWidth, unscaledHeight);
        var g:Graphics = graphics;
        g.clear();
        var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);
        //var rowtotal:int = new int(dp[0].length) ;
        if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))
            return;
        if (data[DataGridListData(listData).dataField]== "NJ")
        {
             g.beginFill(0xCC0033);
             g.drawRect(0, 0, unscaledWidth, unscaledHeight);
             g.endFill();
        }
    }'

解决方案

You have to use a Itemrenderer for achieving this. In the itemrenderer setdata method you can write the condition for the column for changing the background color of the row to the desired color.

这篇关于基于IF语句在Flex中突出显示DataGrid行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆