Hi,

I think, default CellRenderer is mx.controls.Label, so you can not set
the backgroundColor of one particular cell by getting reference of cell.

But one sure way I know, you can write custom cellrenderer which can
lookup in dataprovider or some other style and sets the background
color.

However, wait for DataGrid gurus for their response :)


See the code for example, it is just for example.....


1) ##SimpleCustomCellRenderer.mxml##

<mx:TextInput xmlns:mx="http://www.macromedia.com/2003/mxml";
borderStyle="none" backgroundAlpha="0">
    <mx:Script>
        function setValue(str, item, sel)
        {           
            text = String(item.Price);
            var price:Number = Number(text);
            
            if(price > 100)
            {
               setCellBackgroundColor(0x00FF00, 100);
            }
            else if(price > 1000)
            {
                setCellBackgroundColor(0x00FF00, 100);
            }
        }
        
        function setCellBackgroundColor(newColor, newAlpha)
        {
             
             setStyle("backgroundAlpha", newAlpha==undefined ? 0 :
newAlpha);
             setStyle("backgroundColor", newColor); 
        }
    </mx:Script>
</mx:TextInput>


2) ##CellBgColorTest.mxml##

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:DataGrid id="myGrid" width="350" height="100">
            <mx:columns>
                <mx:Array>
                    <mx:DataGridColumn columnName="Artist"/>
                    <mx:DataGridColumn columnName="Price"
cellRenderer="SimpleCellRenderer"/>
                    <mx:DataGridColumn columnName="Album" />
                </mx:Array>
            </mx:columns>

                <mx:dataProvider>
                    <mx:Array id="arr">
                        <mx:Object Artist=" Kapil" Album="All Time
Favourites" Price="200"/>
                        <mx:Object Artist=" Kapil" Album="Classic Songs"
Price="10"/>
                    </mx:Array>
                </mx:dataProvider>

            </mx:DataGrid>
</mx:Application>



-abdul



-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of sanjayd
Sent: Thursday, June 30, 2005 12:41 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] change background color of a gridCell ?

quick question...does anybody know, how to change the background color 
of a cell in a dataGrid? Thanks in advance. Sanjay





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links



 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to