Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-29-2008, 08:51 PM   #1
Join Date: Oct 2008
Posts: 50
Default how to trigger a custom event from a grid?

I have this DataGrid, and when the user clicks on an item in it, I want to trigger a custom event that I've made to package the data in that item into a custom class that I've made, instantiate the custom event, passing in the data in that custom class as an argument, then handle the results. The problem I'm having is that when I try to assign the custom event to the DataGrid, I get the following error:
ActionScript Code:
cannot resolve attribute 'selectAssemblyEvent' for component type mx.controls.DataGrid

Here's my datagrid:
ActionScript Code:
<mx:DataGrid width="100%" height="50%" id="searchAssemblyGrid" visible="false" itemClick="gridClickHandler(event)" selectAssemblyEvent="selectAssemblyEventHandler(event)">                             <mx:columns>                                 <mx:DataGridColumn headerText="ID" dataField="as_id" />                                 <mx:DataGridColumn headerText="Status" dataField="status" />                                 <mx:DataGridColumn headerText="Release Status" dataField="release_status" />                                 <mx:DataGridColumn headerText="First Name" dataField="customer_first_name" />                                 <mx:DataGridColumn headerText="Last Name" dataField="customer_last_name" />                                 <mx:DataGridColumn headerText="City" dataField="city" />                                 <mx:DataGridColumn headerText="State" dataField="state" />                                 <mx:DataGridColumn headerText="CC Charge" dataField="cc_charge" />                                 <mx:DataGridColumn headerText="Date" dataField="date" />                                 <mx:DataGridColumn headerText="Vendor" dataField="vendor" />                                 <mx:DataGridColumn headerText="Payment" dataField="payment" />                                 <mx:DataGridColumn headerText="Payment Date" dataField="payment_date" />                                 <mx:DataGridColumn headerText="Net" dataField="net" />                             </mx:columns>                         </mx:DataGrid>

my custom event declaration:
ActionScript Code:
<mx:Metadata>     [Event(name="selectAssemblyEvent", type="events.AssemblyEvent")] </mx:Metadata>

The custom event itself:
ActionScript Code:
package events {     import flash.events.Event;         import pkg.Assembly;     public class AssemblyEvent extends Event     {         public var assembly:Assembly;                 public function AssemblyEvent(type:String, assembly:Assembly)         {             super(type);             this.assembly = assembly;         }                 override public function clone():Event         {             return new AssemblyEvent(type, assembly);         }             } }

the event handlers:
ActionScript Code:
private function gridClickHandler(event:ListEvent):void         {             var assemblyData;             assemblyData = event.itemRenderer.data as Assembly;             var assemblyEventObject:AssemblyEvent = new AssemblyEvent("selectAssemblyEvent", assemblyData);             dispatchEvent(assemblyEventObject);         }                 private function selectAssemblyEventHandler(event:AssemblyEvent):void         {                     }

I think that's everything pertaining to the problem. Am I doing something wrong, or can I simply not put the custom event in the DataGrid tag, as the error message seems to imply? I don't understand why that should be, so I assume the error is something else. If it's not, is there some component I can place as an unobtrusive wrapper around the datagrid that won't necessitate me having to go back and restyle it?

j.steele is offline   Reply With Quote

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
creating separate classes for custom event frank grimes ActionScript 3.0 6 06-27-2009 10:55 PM
Custom tabbed menu needing custom event? petay_pan ActionScript 3.0 1 02-18-2008 01:15 PM
Custom event handlers - triggering event listeners on other objects dansumption ActionScript 3.0 2 02-16-2008 10:58 PM
Is a custom event handling class wise? frank grimes ActionScript 3.0 8 07-28-2007 03:25 AM
Trigger and event from combo box item? Dougiemcn Components 3 05-21-2007 06:35 AM

All times are GMT. The time now is 09:28 AM.

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.