Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-30-2012, 01:46 PM   #1
veo
Senior Member
 
Join Date: Aug 2007
Posts: 112
Default [AS3] Access Datagrid custom CellRenderer Object

Currently I have a custom cell renderer that extends CheckBox and implements ICellRenderer.

I've had to override set selected because every time I would select a row in the datagrid, the check box for that row would select, or deselect when moved off of it.

What I'm trying to do is manually select/deselect items from another movieclip (not the mouse click).

The class has a clickHandler in it that would do this, but I can't seem to access it. Calling
ActionScript Code:
myDatagrid.getCellRendererAt(dg.selectedIndex,0).clickHandler()

will throw a 1061: Call to a possibly undefined method clickHandler error.

Below is the class for the custom cell renderer. Any ideas would be appreciated.

ActionScript Code:
package  {         import fl.controls.CheckBox;     import fl.controls.listClasses.ListData;     import fl.controls.listClasses.ICellRenderer;             import flash.events.MouseEvent;         public class CboxRenderer extends CheckBox implements ICellRenderer{         public var _listData:ListData;         public var _data:Object;         private var checkComponent:CheckBox;                 public function CboxRenderer() {             // constructor code             super();             label   = "";             addEventListener(MouseEvent.CLICK,clickHandler);         }                 public function set listData(ld:ListData):void{_listData = ld;}         public function get listData():ListData{return _listData;}                 public function set data(d:Object):void         {             _data = d;             label   = "";         }         public function get data():Object{return _data;}                 public function clickHandler(e:MouseEvent):void{             _selected      = !_selected;             _data.Available = _selected;         }                 override public function get selected():Boolean{return _selected;}         override public function set selected(value:Boolean):void{             _selected   = value;         }     }     }
veo is offline   Reply With Quote
Old 04-30-2012, 01:54 PM   #2
Barna Biro
Senior Member
 
Barna Biro's Avatar
 
Join Date: Nov 2009
Location: LU, Switzerland
Posts: 1,410
Default

Cast whatever is returned by getCellRendererAt() to CboxRenderer since only that object defines the clickHandler() method ( do not forget to pass some event to it or set 'null' as the default value of the event argument in the handler ).
__________________
Titus M. Plautus - Not by age but by capacity is wisdom acquired.

Last edited by Barna Biro; 04-30-2012 at 02:02 PM.
Barna Biro is offline   Reply With Quote
Old 04-30-2012, 02:00 PM   #3
veo
Senior Member
 
Join Date: Aug 2007
Posts: 112
Default

Quote:
Originally Posted by Barna Biro View Post
Cast whatever is returned by getCellRendererAt() to CboxRenderer since only that object defines the clickHandler() method ( do not forget to pass some event to it or set 'null' as the default value of a event argument in the handler ).
Haha... I was JUST about to post that I found the answer. You were absolutely correct. Took me a bit to realize that I wasn't casting it. For anyone that may need clarification on how to do this:

ActionScript Code:
var cb:CboxRenderer= (dg.getCellRendererAt(dg.selectedIndex,0) as CboxRenderer); cb.dispatchEvent(new MouseEvent(MouseEvent.CLICK));

That will call the clickHandler function.

Thanks Again!

Last edited by veo; 04-30-2012 at 02:02 PM.
veo is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:06 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.