User Guide
278 DataGrid component (Flash Professional only)
When the event is triggered, it automatically passes an event object (eventObject) to the
handler. Each event object has properties that contain information about the event. You can
use these properties to write code that handles the event. The
DataGrid.cellPress event’s
event object has three additional properties:
columnIndex A number that indicates the index of the column that was pressed. The first
position is 0.
itemIndex A number that indicates the index of the row that was pressed. The first
position is 0.
type The string "cellPress".
For more information, see “EventDispatcher class” on page 499.
Example
In the following example, a handler called dgListener is defined and passed to
grid.addEventListener() as the second parameter. The event object is captured by the
cellPress handler in the evt_obj parameter. When the cellPress event is broadcast, a
trace statement is sent to the Output panel. With a DataGrid instance named my_dg on the
Stage, paste the following code in the first frame of the main timeline:
// Set up sample data.
my_dg.dataProvider = [{name:"Clark", score:3135}, {name:"Bruce",
score:403}, {name:"Peter", score:25}];
// Create listener object.
var dgListener:Object = new Object();
dgListener.cellPress = function(evt_obj:Object) {
var cell_str:String = "("+evt_obj.columnIndex+", "+evt_obj.itemIndex+")";
trace("The cell at "+cell_str+" has been clicked");
};
// Add listener.
my_dg.addEventListener("cellPress", dgListener);
DataGrid.change
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX Professional 2004.