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?
Thanks,
Jason