Uncategorized
Dispatch Events from a cellRenderer
I am currently very deep in a flex project for work. I am trying to get them to buy into flex as a platform so they have given me some time to put together a flex application, so we can test it on some users and see if they like it.
I have made great progress and learned a ton already. But on thursday I came upon a problem. Yes thats thursday(as in 4 days ago) and I am just now blogging about it.
Anyway, I have a datagrid that lists some information and I wanted to display a button in one of the columns. This is pretty simple to accomplish by using a cellRenderer. I have written several other cellRenderers through this project but none have had any interactive elements.
So I started off with my component, used the mx:MetaData to specify that my component will dispatch and event, and added the action script to fire off my custom event. This all went according to plan. The next step is to add the event as an attribute with some actionscript to execute where I call my custom component. And there begins the problem. A cellRenderer is called as an attribute of the DataGridColumn object (in my case) and therefore I can not arbitrarily add an attribute to its call. I tried just adding this to the DataGridColumn but recieved a compile error because my event is not an acceptable attribute of that object.
After a couple quick searches I had not found any examples or information on this, so I hit the docs. In looking over the cellRenderer API I found some information about declaring a variable that will contain a reference to the parent list object. With this reference I can use the parent objects dispatchEvent method to send out my custom event. The other thing of note here is that the parent object is the list control itself, not the datagridcolumn I thought it was to begin with.
I created a sample application with a couple files so that if someone else run across this problem, they can see an example. If anybody has any ideas on a better way to do this please feel free to let me know.
09 Jan 2006 Simeon

Naw dog, you on track, I did the same thing!
http://www.jessewarden.com/archives/2005/01/datagrid_hyperl.html
Your example didn’t work for me. It threw an error on the "cellEvent" attached to the cellrender call out. The "cellEvent" file in your zipfile had 0 bytes and wasn’t considered a valid file.
I desperately need to get this to work for a project i’m working on so your help would be apprecaited.
Thanks,
Wayne
if this works im gonna find you and kiss you!