Show an event listener for itemEditEnd event using column index, row index, and value properties : DataGrid ItemEditor « Grid « Flex






Show an event listener for itemEditEnd event using column index, row index, and value properties

Show an event listener for itemEditEnd event using column index, row index, and value properties
     


<?xml version="1.0"?>
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.controls.TextInput;
        import mx.events.DataGridEvent;
        import mx.collections.ArrayCollection;
        [Bindable]
        private var myData:ArrayCollection = new ArrayCollection([
            {Artist:'Pavement', Album:'Slanted and Enchanted',Price:11.99},
            {Artist:'Pavement', Album:'Brighten the Corners',Price:11.99 }
        ]);
        private function getCellInfo(event:DataGridEvent):void {
            var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
            var newVal:String = myEditor.text;
            var oldVal:String = event.currentTarget.editedItemRenderer.data[event.dataField];
            cellInfo.text = "cell edited.\n";
            cellInfo.text += "Row, column: " + event.rowIndex + ", " + event.columnIndex + "\n";
            cellInfo.text += "New value: " + newVal + "\n";
            cellInfo.text += "Old value: " + oldVal;
        }
      
    </mx:Script>
    <mx:TextArea id="cellInfo" width="300" height="150" />
    <mx:DataGrid id="myGrid" dataProvider="{myData}" editable="true"
        itemEditEnd="getCellInfo(event);">
        <mx:columns>
            <mx:DataGridColumn dataField="Artist" />
            <mx:DataGridColumn dataField="Album" />
            <mx:DataGridColumn dataField="Price" />
        </mx:columns>
    </mx:DataGrid>
</mx:Application>

   
    
    
    
    
  








Related examples in the same category

1.Use ComboBox as itemEditorUse ComboBox as itemEditor
2.Use an inline item editor, rather than a componentUse an inline item editor, rather than a component
3.Using a DateField or ComboBox control as a drop-in item editorUsing a DateField or ComboBox control as a drop-in item editor
4.Define an event listener for the itemEditEnd event that uses the NumberFormatter class to format cell valueDefine an event listener for the itemEditEnd event that uses the NumberFormatter class to format cell value
5.Use itemEditEnd event to ensure that the user did not enter an empty StringUse itemEditEnd event to ensure that the user did not enter an empty String
6.To prevent cell editing, call the preventDefault() method from within your event listenerTo prevent cell editing, call the preventDefault() method from within your event listener
7.Inline CheckBox Editor With OffsetsInline CheckBox Editor With Offsets
8.Returning data from an item editorReturning data from an item editor
9.Use mx.controls.NumericStepper as DataGridColumn editorUse mx.controls.NumericStepper as DataGridColumn editor
10.use to define an inline item editoruse <mx:Component> to define an inline item editor
11.inline item editor contains a single control that supports the data propertyinline item editor contains a single control that supports the data property
12.DataGrid Dropin Editor
13.Inline DataGrid EditorInline DataGrid Editor
14.Cancel the edit action and maintain edit stateCancel the edit action and maintain edit state
15.Get cell index in cell onEditEnd eventGet cell index in cell onEditEnd event
16.Edited Row and columnEdited Row and column
17.Item Editor Size and PositionItem Editor Size and Position
18.Item Edit Beginning EventItem Edit Beginning Event
19.Item Edit End EventItem Edit End Event