In this exercise you will use the itemClick event to
handle a user click on the DataGrid control (see Figure 1).

Figure 1. Review your task for this exercise.
In this exercise, you will learn how to:
In order to complete this tutorial, you need the following software and files:
In this section, you will assign the itemClick event to
display information from the data object selected.
UI components comment, locate the DataGrid control. To the DataGrid control, use the code assist tool to generate the itemClick event (see
Figure 2).

Figure 2. Generate the itemClick event for the DataGrid control.
Use the code assist tool
to generate a click handler function for the itemClick event (see
Figure 3).

Figure 3. Use the code assist tool to generate an event handler function for the itemClick event.
Script block, locate the employeeDataGrid_itemClickHandler() function. Within the function,
remove the generated code and assign event.target.selectedItem.firstName as the employeeName
Label control's text value:
protected function employeeDataGrid_itemClickHandler(event:ListEvent):void
{
employeeName.text = event.target.selectedItem.firstName;
}
Below the employeeName.text assignment, assign the employeeImage Image control's source property to the employee image located in the images directory using the
employee id value from the data:
protected function
employeeDataGrid_itemClickHandler(event:ListEvent):void
{
employeeName.text = event.target.selectedItem.firstName;
employeeImage.source = "images/"
+ event.target.selectedItem.id + ".jpg";
}
Click on an employee item in the DataGrid control.
You should see the employees first name and image displayed
below the DataGrid control (see Figure 4).

Figure 4. Click an employee to display their first name and image below the DataGrid control.
In this exercise, you learned how to use the itemClick event to handle a user click within a DataGrid control.
DataGrid control?itemClick event.Trilemetry, Inc is a development and education organization that implements a human-centered design approach to the creation of software and content. Their Adobe portfolio includes the Adobe ColdFusion Getting Started Experience, the Adobe Flex Getting Started Experience, the Flex in a Week video series, the official Adobe instructor-led training course Flex 3: Extending and Styling Components and more. They also create and support many Web applications from interactive Flash sites and corporate web sites to mission-critical business applications.