|
The “color” style of Text only
affects the text and the not the background. Text doesn’t actually have a
background color so you must create an itemRenderer with a backgroundColor and
then set it. This example was posted on another flexcoders thread entitled “datagrid”.
This itemRenderer will turn the background of a row to red if the value of the
column “myColumnName” in that row is over 50. package { import mx.controls.Label; import
mx.controls.dataGridClasses.*; import mx.controls.DataGrid; import flash.display.Graphics; import mx.styles.StyleManager;
[Style(name="backgroundColor", type="uint",
format="Color", inherit="no")] public class
BackgroundComp extends Label { 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);
if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data))
return;
if (data.myColumnName > 50)
{
g.beginFill(0xFF0000);
g.drawRect(0, 0, unscaledWidth, unscaledHeight);
g.endFill();
} } } } From:
-- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [flexcoders] Re: coloring an entire cell in a DataGrid? Tim Hoff
- RE: [flexcoders] Re: coloring an entire cell in a Da... Joan Tan
- Re: [flexcoders] Re: coloring an entire cell in ... Jeremy Lu
- RE: [flexcoders] Re: coloring an entire cell... Joan Tan
- Re: [flexcoders] Re: coloring an entire ... Jeremy Lu
- [flexcoders] Re: coloring an entire... djbrown_rotonews
- [flexcoders] Re: coloring an en... djbrown_rotonews
- Re: [flexcoders] Re: colori... Jeremy Lu
- [flexcoders] Re: coloring a... djbrown_rotonews
- RE: [flexcoders] Re: colori... Joan Tan
- Re: [flexcoders] Re: colori... Jeremy Lu
- RE: [flexcoders] Re: colori... Joan Tan

