1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| <?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundColor="#F1F1F1"
>
<mx:Script>
<![CDATA[
//* ======*======*======*=====* *=====*======*======*====== *//
//* ======*======*======*=====* SCRIPT BEGIN *=====*======*======*====== *//
//* ======*======*======*=====* *=====*======*======*====== *//
import com.inm.framework.utils.Debug;
import mx.controls.listClasses.IDropInListItemRenderer;
import mx.events.DataGridEvent;
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
//* FIELDS (PRIVATE)
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
private var savedData:Object = null;
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
//* HANDLERS
//* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ******
private function changeHandler(ev:Event):void
{
ev.currentTarget.data = savedData;
}
private function itemEditBeginHandler(ev:DataGridEvent):void
{
// Handle the event here.
ev.preventDefault();
// Creates an item editor.
dataGrid1.createItemEditor(ev.columnIndex, ev.rowIndex);
// All item editors must implement the IDropInListItemRenderer interface
// and the listData property.
// Initialize the listData property of the editor.
IDropInListItemRenderer(dataGrid1.itemEditorInstance).listData =
IDropInListItemRenderer(dataGrid1.editedItemRenderer).listData;
// Copy the cell value to the NumericStepper control.
dataGrid1.itemEditorInstance.data = dataGrid1.editedItemRenderer.data;
savedData = dataGrid1.itemEditorInstance.data ;
dataGrid1.itemEditorInstance.addEventListener(Event.CHANGE,
changeHandler);
}
private function itemEditEndHandler(ev:DataGridEvent):void
{
dataGrid1.editedItemRenderer.data = savedData;
dataGrid1.itemEditorInstance.removeEventListener(Event.CHANGE,
changeHandler);
}
//* ======*======*======*=====* *=====*======*======*====== *//
//* ======*======*======*=====* SCRIPT END *=====*======*======*====== *//
//* ======*======*======*=====* *=====*======*======*====== *//
]]>
</mx:Script>
<mx:DataGrid id="dataGrid1"
editable="true"
itemEditBegin="itemEditBeginHandler(event)"
itemEditEnd="itemEditEndHandler(event)"
>
<mx:ArrayCollection>
<mx:Object>
<mx:Artist>Moi</mx:Artist>
<mx:Price>10.00</mx:Price>
<mx:Album>Album1</mx:Album>
</mx:Object>
<mx:Object>
<mx:Artist>Moi</mx:Artist>
<mx:Price>20.00</mx:Price>
<mx:Album>Album2</mx:Album>
</mx:Object>
</mx:ArrayCollection>
</mx:DataGrid>
</mx:Canvas> |
Partager