Hi,

I am trying to change the color of the entire single row of a datagrid using cellRenderer. I don’t have much experience using CellRenderer or RowRenderer and have not seen any example where a cellRenderer changes the property or backgroundColor of entire row. The CellRenderer  setValue() below gives me “[Fault] recursion_limit”. If anybody has working example to achieve this would be really helpful.

 

    function setValue(str:String, item:Object, sel:Boolean) : Void

        {          

            text = String(item.Price);

            var price:Number = Number(text);

            if(price > 100)

            {

                           listOwner.dataProvider.editField(getCellIndex().itemIndex, "backgroundColor", "0x00FFFF");

            }

        } else ……

 

 

Thanks,


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Matt Chotin
Sent: Tuesday, December 06, 2005 8:48 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Datagrid Issue

 

listOwner.dataProvider.editField(getCellIndex().itemIndex, “backgroundColor”, 0x00ffff)

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of shahnavaz Alware
Sent: Tuesday, December 06, 2005 4:11 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Datagrid Issue

 

Thanks Matt,

 

I was under the impression that when datagrid sort, will clean itself off. Using the same example how I can make the cellRenderer change the color of entire row where Price > 100? I did tried using listOwner[getCellIndex().itemIndex].setStyle("backgroundColor", 0x00FFFF) with no luck.

 

Thanks,

 

Shahn

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Matt Chotin
Sent: Monday, December 05, 2005 6:16 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Datagrid Issue

 

Well you still need an else so that you call setBackgroundColor even when price is less than 100.  The cell is re-used, you need to cover all cases in your setValue function.  So your else statement here can be to setCellBackgroundColor(0xffffff, 0)

 

Matt

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Shahnavaz Alware
Sent: Monday, December 05, 2005 5:17 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Datagrid Issue

 

Hi Matt,

 

The code is not the problem here. I am not sure if I have to reassign the dataprovider after I click on Price header. I replaced the script so now I am just checking for Price > 100 and when you sort by price after it renders the result is still the same.

 

 

    <mx:Script>

    <![CDATA[  

        function setValue(str, item, sel)

        {          

            text = String(item.Price);

            var price:Number = Number(text);

            if(price > 100)

            {

               setCellBackgroundColor(0x00FF00, 100);

            }

        }

       

        function setCellBackgroundColor(newColor, newAlpha)

        {

            

             setStyle("backgroundAlpha", newAlpha==undefined ? 0 :newAlpha);

             setStyle("backgroundColor", newColor);

        }   

            ]]>

    </mx:Script>

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Matt Chotin
Sent: Monday, December 05, 2005 5:04 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Datagrid Issue

 

Don’t you need a check for < 1000 in your if (price > 100) test?

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Shahnavaz Alware
Sent: Monday, December 05, 2005 4:59 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Datagrid Issue

 

Hi,

 

I am using a cellRenderer in my datagrid. Now when I sort by clicking on header the DatagridColumns on which I have cellRenderer never cleans up the cell which was rendered by cellRenderer. How can I solve this issue? Files and screen Image below.

<!—Application à

<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="SimpleCustomCellRenderer"/>

                    <mx:DataGridColumn columnName="Album" />

                </mx:Array>

            </mx:columns>

 

                <mx:dataProvider>

                    <mx:Array id="arr">

                        <mx:Object Artist=" Kapil" Album="All Time Favourites" Price="101"/>

                        <mx:Object Artist=" Kapil" Album="Classic Songs" Price="10"/>

                    </mx:Array>

                </mx:dataProvider>

 

            </mx:DataGrid>

</mx:Application>

 

<!—CellRendererà

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

 

 

After Sorting on Price

 

 

Thanks,

 

Shahn

 

 









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




Reply via email to