Macromedia Flex Macromedia Flex
Change vs Click in the Flex 2 DataGrid

May 24, 2006 - Change vs Click in the Flex 2 DataGrid
Using an Event Listener to handle a click event in the DG in Flex2

In learning Flex 2, instead of binding directly to the dataGrid (as all the examples seem to do), I wanted to handle that using an event listener (the docs seem to use the term event listener, when in my opinion a function that handles the result of an event, is an event handler).

Anyways, I found this can be accomplished by either using the change or the click events. After testing both I can't really see the difference, other than the change event seems to be of a more generic level by firing off a plain Event, where as the click event fires off a MouseEvent.

Other subtle differences is that the change Event has, where as the click MouseEvent uses an event.currentTarget.

Using a Click Handler:

<mx:DataGrid id="DG1" click="clickHandler(event)"/>
  public function clickHandler(event:MouseEvent):void
      someControl.text = event.currentTarget.selectedItem.someDataField;

Using a Change Handler:

<mx:DataGrid id="DG2" change="changeHandler(event)"/>
  public function changeHandler(event:Event):void
      someControl.text =;

File Details
Created On May, 24, 2006 by Scott Russel
Last Modified On May, 24, 2006 by Scott Russel
Group: Tips and Articles
Flex Versions: 2.0
Category: Controls:Lists (eg DataGrid/Tile/Tree)
Type: Tip
Difficulty: Beginner