RE: [flexcoders] Why is this renderer so slow?

2008-05-27 Thread Tracy Spratt
An ordinary CheckBox will not retain its state when used as an
itemRenderer.  Renderers are recycled and will not reliably keep any
state.

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of leds usop
Sent: Saturday, May 24, 2008 2:25 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Why is this renderer so slow?

 

im just wondering why you think an ordinary check box wont retain it's
selected state when scrolling? can you provide an example code that does
that? maybe it will be more beneficial to approach the problem using
that approach. Just a thought. 


--- On Sun, 5/25/08, dbronk [EMAIL PROTECTED] wrote:

From: dbronk [EMAIL PROTECTED]
Subject: [flexcoders] Why is this renderer so slow?
To: flexcoders@yahoogroups.com
Date: Sunday, May 25, 2008, 12:59 AM

I have created a checkbox renderer. My datagrid has 5 out of 8
columns that use it. The datagrid has only about 80 rows it it. When
using this renderer the performance of the datagrid is horrible. 
Scrolling is extremely slow, click a checkbox is extremely slow. If I
swap out and use a normal mx:CheckBox for the renderer the performance
is just fine, but of course that doesn't work as it will not retain
the state of the checkbox when scrolling. Here is my code for the
renderer. I notice that many of these are re-executed whenever
anything happens to the datagrid. That includes just mousing over.

Thanks.

Dale

package renderer
{
import flash.events. MouseEvent;

import mx.controls. CheckBox;

import spectrumk12. minerva.util. BaseEvent;
import spectrumk12. minerva.util. Utils;

[Event(name= selectionSet , type=util.BaseEven t)]
public class RendererCheckBoxXML extends CheckBox
{
private var _xmlItem : XML; //holds the current item xml node
private var count:int=0;
private var debug:String= ;

/** The attribute in the xml to use to store the selected state of
this checkbox. */
[Inspectable( default= rendererSelected )]
public var selectedAttribute : String = rendererSelected ;

/** The default selection state (true/false) to give if the
selectedAttribute is not there or null */
[Inspectable( default= false, enumeration= true,false )]
public var defaultSelectedStat e : Boolean = false;

public function RendererCheckBoxXML ()
{
super();
trace(RendererChec kBoxXML:Construc tor);
this.addEventListen er(MouseEvent. CLICK, onClick, false, 0, true);
}

// Sets the state of the checkbox based on the selectedAttribute
attribute.
override public function set data(oItem:Object) : void
{
_xmlItem = XML(oItem);
trace(RendererChec kBoxXML:set data:  + [EMAIL PROTECTED]) ;
var bSelected : Boolean = false;
var attrSelected : String = [EMAIL PROTECTED] Attribute] ;
this.selected = ( Utils.nullOrBlank( attrSelected) ?
defaultSelectedStat e : (attrSelected == true) ); 
}

override public function get data() : Object
{
trace(RendererChec kBoxXML:get data:  + (_xmlItem != null ?
[EMAIL PROTECTED] : null));
return _xmlItem;
}

/**
* This overridden function is where the logic is for updating the xml.
*/
override public function set selected(selectedFl ag:Boolean) : void
{
trace(RendererChec kBoxXML:set selected:  + [EMAIL PROTECTED]) ;
super.selected = selectedFlag;

// Only update the xml if it needs to be updated. Each time the xml
// is updated it will fire any bindings to it so we want to keep these
// to a minimum.
if ( [EMAIL PROTECTED] Attribute] != selectedFlag )
{
// The selected flag is different than the selectedAttribute
attribute.
// Now we make one last check to see if the selectedFlag is false and
// there is no attribute selectedAttribute. If this is the case, then
// we do NOT update because having no attribute selectedAttribute will
// default to a false. Again, we do this so that we update the xml as
// infrequently as possible.
if ( selectedFlag || [EMAIL PROTECTED] Attribute] .length()  0 )
{
[EMAIL PROTECTED] Attribute] = String(this. selected) ; //set the
checkbox state into the dataProvider
}
}
dispatchEvent( new BaseEvent(selectio nSet, selectedFlag) );
}

// Called by click of the checkbox
private function onClick(mouseEvent: MouseEvent) : void
{
trace(RendererChec kBoxXML:onClick:  + [EMAIL PROTECTED]) ;
// Simply need to trigger the set selected function as that is
where the logic for updating the xml is.
this.selected = this.selected; 
}

}
}

 

 



[flexcoders] Why is this renderer so slow?

2008-05-24 Thread dbronk
I have created a checkbox renderer.  My datagrid has 5 out of 8
columns that use it.  The datagrid has only about 80 rows it it.  When
using this renderer the performance of the datagrid is horrible. 
Scrolling is extremely slow, click a checkbox is extremely slow.  If I
swap out and use a normal mx:CheckBox for the renderer the performance
is just fine, but of course that doesn't work as it will not retain
the state of the checkbox when scrolling.  Here is my code for the
renderer.  I notice that many of these are re-executed whenever
anything happens to the datagrid.  That includes just mousing over.

Thanks.

Dale

package renderer
{
import flash.events.MouseEvent;

import mx.controls.CheckBox;

import spectrumk12.minerva.util.BaseEvent;
import spectrumk12.minerva.util.Utils;

[Event(name=selectionSet, type=util.BaseEvent)]
public class RendererCheckBoxXML extends CheckBox
{
private var _xmlItem : XML;//holds the current item xml node
private var count:int=0;
private var debug:String=;

/** The attribute in the xml to use to store the selected state 
of
this checkbox. */
[Inspectable(default=rendererSelected)]
public var selectedAttribute : String = rendererSelected;

/** The default selection state (true/false) to give if the
selectedAttribute is not there or null */
[Inspectable(default=false, enumeration=true,false)]
public var defaultSelectedState : Boolean = false;

public function RendererCheckBoxXML()
{
super();
trace(RendererCheckBoxXML:Constructor);
this.addEventListener(MouseEvent.CLICK, onClick, false, 
0, true);
}

// Sets the state of the checkbox based on the selectedAttribute
attribute.
override public function set data(oItem:Object) : void
{
_xmlItem = XML(oItem);
trace(RendererCheckBoxXML:set data:  + [EMAIL 
PROTECTED]);
var bSelected : Boolean = false;
var attrSelected : String = [EMAIL PROTECTED];
this.selected = ( Utils.nullOrBlank(attrSelected) ?
defaultSelectedState : (attrSelected == true) ); 
}
 
override public function get data() : Object
{
trace(RendererCheckBoxXML:get data:  + (_xmlItem != 
null ?
[EMAIL PROTECTED] : null));
return _xmlItem;
}

/**
 * This overridden function is where the logic is for updating 
the xml.
 */
override public function set selected(selectedFlag:Boolean) : 
void
{
trace(RendererCheckBoxXML:set selected:  + [EMAIL 
PROTECTED]);
super.selected = selectedFlag;

// Only update the xml if it needs to be updated.  Each 
time the xml
// is updated it will fire any bindings to it so we 
want to keep these
// to a minimum.
if ( [EMAIL PROTECTED] != selectedFlag )
{
// The selected flag is different than the 
selectedAttribute
attribute.
// Now we make one last check to see if the 
selectedFlag is false and
// there is no attribute selectedAttribute.  If 
this is the case, then
// we do NOT update because having no attribute 
selectedAttribute will
// default to a false.  Again, we do this so 
that we update the xml as
// infrequently as possible.
if ( selectedFlag || [EMAIL PROTECTED]()  0 )
{
[EMAIL PROTECTED] = 
String(this.selected);  //set the
checkbox state into the dataProvider
}
}
dispatchEvent(new BaseEvent(selectionSet, 
selectedFlag));
}

// Called by click of the checkbox
private function onClick(mouseEvent:MouseEvent) : void
{
trace(RendererCheckBoxXML:onClick:  + [EMAIL 
PROTECTED]);
// Simply need to trigger the set selected function as 
that is
where the logic for updating the xml is.
this.selected = this.selected; 
}

}
}



Re: [flexcoders] Why is this renderer so slow?

2008-05-24 Thread leds usop
im just wondering why you think an ordinary check box wont retain it's selected 
state when scrolling? can you provide an example code that does that? maybe it 
will be more beneficial to approach the problem using that approach. Just a 
thought. 


--- On Sun, 5/25/08, dbronk lt;[EMAIL PROTECTED]gt; wrote:
From: dbronk lt;[EMAIL PROTECTED]gt;
Subject: [flexcoders] Why is this renderer so slow?
To: flexcoders@yahoogroups.com
Date: Sunday, May 25, 2008, 12:59 AM

I have created a checkbox renderer.  My datagrid has 5 out of 8
 columns that use it.  The datagrid has only about 80 rows it it.  When
 using this renderer the performance of the datagrid is horrible. 
 Scrolling is extremely slow, click a checkbox is extremely slow.  If I
 swap out and use a normal mx:CheckBox for the renderer the performance
 is just fine, but of course that doesn't work as it will not retain
 the state of the checkbox when scrolling.  Here is my code for the
 renderer.  I notice that many of these are re-executed whenever
 anything happens to the datagrid.  That includes just mousing over.

 Thanks.

 Dale

 package renderer
 {
import flash.events. MouseEvent;

import mx.controls. CheckBox;

import spectrumk12. minerva.util. BaseEvent;
import spectrumk12. minerva.util. Utils;

[Event(name= selectionSet , type=util.BaseEven t)]
public class RendererCheckBoxXML extends CheckBox
{
private var _xmlItem : XML;//holds the current item xml node
private var count:int=0;
private var debug:String= ;

/** The attribute in the xml to use to store the selected state 
of
 this checkbox. */
[Inspectable( default= rendererSelected )]
public var selectedAttribute : String = rendererSelected ;

/** The default selection state (true/false) to give if the
 selectedAttribute is not there or null */
[Inspectable( default= false, enumeration= true,false )]
public var defaultSelectedStat e : Boolean = false;

public function RendererCheckBoxXML ()
{
super();
trace(RendererChec kBoxXML:Construc tor);
this.addEventListen er(MouseEvent. CLICK, onClick, 
false, 0, true);
}

// Sets the state of the checkbox based on the selectedAttribute
 attribute.
override public function set data(oItem:Object) : void
{
_xmlItem = XML(oItem);
trace(RendererChec kBoxXML:set data:  + [EMAIL 
PROTECTED]) ;
var bSelected : Boolean = false;
var attrSelected : String = [EMAIL PROTECTED] 
Attribute] ;
this.selected = ( Utils.nullOrBlank( attrSelected) ?
 defaultSelectedStat e : (attrSelected == true) ); 
}

override public function get data() : Object
{
trace(RendererChec kBoxXML:get data:  + (_xmlItem != 
null ?
 [EMAIL PROTECTED] : null));
return _xmlItem;
}

/**
 * This overridden function is where the logic is for updating 
the xml.
 */
override public function set selected(selectedFl ag:Boolean) : 
void
{
trace(RendererChec kBoxXML:set selected:  + [EMAIL 
PROTECTED]) ;
super.selected = selectedFlag;

// Only update the xml if it needs to be updated.  Each 
time the xml
// is updated it will fire any bindings to it so we 
want to keep these
// to a minimum.
if ( [EMAIL PROTECTED] Attribute] != selectedFlag )
{
// The selected flag is different than the 
selectedAttribute
 attribute.
// Now we make one last check to see if the 
selectedFlag is false and
// there is no attribute selectedAttribute.  If 
this is the case, then
// we do NOT update because having no attribute 
selectedAttribute will
// default to a false.  Again, we do this so 
that we update the xml as
// infrequently as possible.
if ( selectedFlag || [EMAIL PROTECTED] 
Attribute] .length() gt; 0 )
{
[EMAIL PROTECTED] Attribute] = 
String(this. selected) ; //set the
 checkbox state into the dataProvider
}
}
dispatchEvent( new BaseEvent(selectio nSet, 
selectedFlag

Re: [flexcoders] Why is this renderer so slow?

2008-05-24 Thread Douglas Knudsen
ugh,yeah, CheckBox implements  IDropInItemListRenderer (or whatever its
called exactly) and can do the edit your data thing.  Have you tried this?

DK

On Sat, May 24, 2008 at 2:25 PM, leds usop [EMAIL PROTECTED] wrote:

   im just wondering why you think an ordinary check box wont retain it's
 selected state when scrolling? can you provide an example code that does
 that? maybe it will be more beneficial to approach the problem using that
 approach. Just a thought.


 --- On *Sun, 5/25/08, dbronk [EMAIL PROTECTED]* wrote:

 From: dbronk [EMAIL PROTECTED]
 Subject: [flexcoders] Why is this renderer so slow?
 To: flexcoders@yahoogroups.com
 Date: Sunday, May 25, 2008, 12:59 AM

 I have created a checkbox renderer. My datagrid has 5 out of 8
 columns that use it. The datagrid has only about 80 rows it it. When
 using this renderer the performance of the datagrid is horrible.
 Scrolling is extremely slow, click a checkbox is extremely slow. If I
 swap out and use a normal mx:CheckBox for the renderer the performance
 is just fine, but of course that doesn't work as it will not retain
 the state of the checkbox when scrolling. Here is my code for the
 renderer. I notice that many of these are re-executed whenever
 anything happens to the datagrid. That includes just mousing over.

 Thanks.

 Dale

 package renderer
 {
 import flash.events. MouseEvent;

 import mx.controls. CheckBox;

 import spectrumk12. minerva.util. BaseEvent;
 import spectrumk12. minerva.util. Utils;

 [Event(name= selectionSet , type=util.BaseEven t)]
 public class RendererCheckBoxXML extends CheckBox
 {
 private var _xmlItem : XML; //holds the current item xml node
 private var count:int=0;
 private var debug:String= ;

 /** The attribute in the xml to use to store the selected state of
 this checkbox. */
 [Inspectable( default= rendererSelected )]
 public var selectedAttribute : String = rendererSelected ;

 /** The default selection state (true/false) to give if the
 selectedAttribute is not there or null */
 [Inspectable( default= false, enumeration= true,false )]
 public var defaultSelectedStat e : Boolean = false;

 public function RendererCheckBoxXML ()
 {
 super();
 trace(RendererChec kBoxXML:Construc tor);
 this.addEventListen er(MouseEvent. CLICK, onClick, false, 0, true);
 }

 // Sets the state of the checkbox based on the selectedAttribute
 attribute.
 override public function set data(oItem:Object) : void
 {
 _xmlItem = XML(oItem);
 trace(RendererChec kBoxXML:set data:  + [EMAIL PROTECTED]) ;
 var bSelected : Boolean = false;
 var attrSelected : String = [EMAIL PROTECTED] Attribute] ;
 this.selected = ( Utils.nullOrBlank( attrSelected) ?
 defaultSelectedStat e : (attrSelected == true) );
 }

 override public function get data() : Object
 {
 trace(RendererChec kBoxXML:get data:  + (_xmlItem != null ?
 [EMAIL PROTECTED] : null));
 return _xmlItem;
 }

 /**
 * This overridden function is where the logic is for updating the xml.
 */
 override public function set selected(selectedFl ag:Boolean) : void
 {
 trace(RendererChec kBoxXML:set selected:  + [EMAIL PROTECTED]) ;
 super.selected = selectedFlag;

 // Only update the xml if it needs to be updated. Each time the xml
 // is updated it will fire any bindings to it so we want to keep these
 // to a minimum.
 if ( [EMAIL PROTECTED] Attribute] != selectedFlag )
 {
 // The selected flag is different than the selectedAttribute
 attribute.
 // Now we make one last check to see if the selectedFlag is false and
 // there is no attribute selectedAttribute. If this is the case, then
 // we do NOT update because having no attribute selectedAttribute will
 // default to a false. Again, we do this so that we update the xml as
 // infrequently as possible.
 if ( selectedFlag || [EMAIL PROTECTED] Attribute] .length()  0 )
 {
 [EMAIL PROTECTED] Attribute] = String(this. selected) ; //set the
 checkbox state into the dataProvider
 }
 }
 dispatchEvent( new BaseEvent(selectio nSet, selectedFlag) );
 }

 // Called by click of the checkbox
 private function onClick(mouseEvent: MouseEvent) : void
 {
 trace(RendererChec kBoxXML:onClick:  + [EMAIL PROTECTED]) ;
 // Simply need to trigger the set selected function as that is
 where the logic for updating the xml is.
 this.selected = this.selected;
 }

 }
 }


  




-- 
Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?


RE: [flexcoders] Why is this renderer so slow?

2008-05-24 Thread Alex Harui
Updating the dataprovider is costly. Make sure it only happens when
required (that is isn't happening during scrolling), and maybe avoid
dispatching an event to do it.  I'm not sure who's listening and what
they will do in response.  If you change the dataprovider, the DataGrid
will do a lot of work.

 

XML is much slower than objects, so it may pay to convert to object.

 

Button already has logic for handling a selectedField in a dataprovider
item.  Since CheckBox inherits from button, you might just be able to
use selectedField, or modify and piggy-back on its timing.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of dbronk
Sent: Saturday, May 24, 2008 10:00 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Why is this renderer so slow?

 

I have created a checkbox renderer. My datagrid has 5 out of 8
columns that use it. The datagrid has only about 80 rows it it. When
using this renderer the performance of the datagrid is horrible. 
Scrolling is extremely slow, click a checkbox is extremely slow. If I
swap out and use a normal mx:CheckBox for the renderer the performance
is just fine, but of course that doesn't work as it will not retain
the state of the checkbox when scrolling. Here is my code for the
renderer. I notice that many of these are re-executed whenever
anything happens to the datagrid. That includes just mousing over.

Thanks.

Dale

package renderer
{
import flash.events.MouseEvent;

import mx.controls.CheckBox;

import spectrumk12.minerva.util.BaseEvent;
import spectrumk12.minerva.util.Utils;

[Event(name=selectionSet, type=util.BaseEvent)]
public class RendererCheckBoxXML extends CheckBox
{
private var _xmlItem : XML; //holds the current item xml node
private var count:int=0;
private var debug:String=;

/** The attribute in the xml to use to store the selected state of
this checkbox. */
[Inspectable(default=rendererSelected)]
public var selectedAttribute : String = rendererSelected;

/** The default selection state (true/false) to give if the
selectedAttribute is not there or null */
[Inspectable(default=false, enumeration=true,false)]
public var defaultSelectedState : Boolean = false;

public function RendererCheckBoxXML()
{
super();
trace(RendererCheckBoxXML:Constructor);
this.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
}

// Sets the state of the checkbox based on the selectedAttribute
attribute.
override public function set data(oItem:Object) : void
{
_xmlItem = XML(oItem);
trace(RendererCheckBoxXML:set data:  + [EMAIL PROTECTED]);
var bSelected : Boolean = false;
var attrSelected : String = [EMAIL PROTECTED];
this.selected = ( Utils.nullOrBlank(attrSelected) ?
defaultSelectedState : (attrSelected == true) ); 
}

override public function get data() : Object
{
trace(RendererCheckBoxXML:get data:  + (_xmlItem != null ?
[EMAIL PROTECTED] : null));
return _xmlItem;
}

/**
* This overridden function is where the logic is for updating the xml.
*/
override public function set selected(selectedFlag:Boolean) : void
{
trace(RendererCheckBoxXML:set selected:  + [EMAIL PROTECTED]);
super.selected = selectedFlag;

// Only update the xml if it needs to be updated. Each time the xml
// is updated it will fire any bindings to it so we want to keep these
// to a minimum.
if ( [EMAIL PROTECTED] != selectedFlag )
{
// The selected flag is different than the selectedAttribute
attribute.
// Now we make one last check to see if the selectedFlag is false and
// there is no attribute selectedAttribute. If this is the case, then
// we do NOT update because having no attribute selectedAttribute will
// default to a false. Again, we do this so that we update the xml as
// infrequently as possible.
if ( selectedFlag || [EMAIL PROTECTED]()  0 )
{
[EMAIL PROTECTED] = String(this.selected); //set the
checkbox state into the dataProvider
}
}
dispatchEvent(new BaseEvent(selectionSet, selectedFlag));
}

// Called by click of the checkbox
private function onClick(mouseEvent:MouseEvent) : void
{
trace(RendererCheckBoxXML:onClick:  + [EMAIL PROTECTED]);
// Simply need to trigger the set selected function as that is
where the logic for updating the xml is.
this.selected = this.selected; 
}

}
}