When the event is triggered, it automatically passes an event object (
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
event object has four additional properties:
A number that indicates the index of the target column.
columnIndex
A number that indicates the index of the target row.
itemIndex
The previous value of the cell.
oldValue
The string
type
"cellEdit"
For more information, see
Example
In the following example, a handler called
myDataGrid.addEventListener()
the
handler in the
cellEdit
(after you alter a "score" value and press Enter), a
With a DataGrid instance named
frame of the main timeline:
my_dg.setSize(320, 240);
my_dg.editable = true;
// Add columns and make the first one not editable.
my_dg.addColumn("name");
my_dg.getColumnAt(0).editable = false;
my_dg.addColumn("score");
var myDP_array:Array = new Array();
myDP_array.push({name:"Clark", score:3135});
myDP_array.push({name:"Bruce", score:403});
myDP_array.push({name:"Peter", score:25});
// Set data source of DataGrid.
my_dg.dataProvider = myDP_array;
// Create listener object.
var myListener_obj:Object = new Object();
myListener_obj.cellEdit = function(evt_obj:Object) {
// Retrieve location of cell that was changed.
var cell_obj:Object = "("+evt_obj.columnIndex+", "+evt_obj.itemIndex+")";
// Retrieve cell value that was changed.
var value_obj:Object = evt_obj.target.selectedItem.score;
trace("The value of the cell at "+cell_obj+" has changed to "+value_obj);
};
// Add listener object.
my_dg.addEventListener("cellEdit", myListener_obj);
.
"EventDispatcher class" on page
myDataGridListener
as the second parameter. The event object is captured by
parameter. When the
eventObject
on the Stage, paste the following code in the first
my_dg
eventObject
DataGrid.cellEdit
499.
is defined and passed to
cellEdit
statement is sent to the Output panel.
trace
) to the
event's
event is broadcast
DataGrid.cellEdit
273
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?
Questions and answers