Hi all,

I have a simple button renderer (below) which I use in my datagrids.  
All seemed fine but I now have four of these button renderers in each 
row of my datagrid(s) and performance starts to suffer when there are 
many rows on display at once (my app can easily have a hundred or 
more rows on display in various datagrids).

I've noticed that when a row's data changes, the updateDisplayList 
function is called on every button renderer in that row.  Does anyone 
know why this is or how I can stop it happening?  The row data does 
not affect the visual appearance of the button so there is no need to 
redraw it every time the row data changes.  I'm thinking this 
constant redrawing of the buttons might be the cause of the 
performance issues as I could quite easily have, say, 400 button 
renderers on screen at once and the row data changes quite frequently.

Any ideas?

This is my button renderer:

<?xml version="1.0" encoding="utf-8"?>
<mx:Button xmlns:mx="http://www.adobe.com/2006/mxml"; initialize="init
();">
        <mx:Script>
                <![CDATA[
                        import custom.DataGridButtonClickEvent;

                        //action to request when button is clicked
                        public var action:String;

                        //a copy of the data passed in to send back 
if the button is clicked
                        private var _data:Object;

                        //listen for button click events
                        private function init():void
                        {
                                this.addEventListener
(MouseEvent.CLICK, onClick);
                        }

                        //called when grid data changes or scrolls - 
determine button enabled status
                        override public function set data
(value:Object):void
                        {
                                if (value != null)
                                {
                                        _data = value;
                                }
                        }

                        //local click handler to dispatch a custom 
event containing the requested action
                        private function onClick(e:MouseEvent):void
                        {
                                //dispatch an event containing the 
row data and requested action
                                if ((enabled) && (action))
                                {
                                        dispatchEvent(new 
DataGridButtonClickEvent(_data, this.id, action, true, true));
                                }
                        }
                ]]>
        </mx:Script>
</mx:Button>

Thanks,

Nick.


Reply via email to