Highlighting a DataGrid row in Flex based on an IF Statement

馋奶兔 提交于 2019-12-25 04:53:14

问题


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();
        }
    }'

回答1:


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.



来源:https://stackoverflow.com/questions/20371731/highlighting-a-datagrid-row-in-flex-based-on-an-if-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!