问题
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