Cancel the edit action and maintain edit state : DataGrid ItemEditor « Grid « Flex






Cancel the edit action and maintain edit state

Cancel the edit action and maintain edit state
           

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        import mx.events.DataGridEvent;
        import mx.validators.EmailValidator;
        import mx.controls.TextInput;
        
        [Bindable]
        public var myAC:ArrayCollection = new ArrayCollection([
            {name:"a", email:"a@i.com"},
            {name:"b", email:"b@i.com"}]);
        
        private function onEditEnd(event:DataGridEvent):void
        {
            if(event.dataField == 'email'){
                 var fCell:Array=[event.columnIndex,event.rowIndex];
                 event.preventDefault();
                 callLater(maintainEdit,fCell);
            }
        }
        private function maintainEdit(colIndex:int,rowIndex:int):void {
            var editCell:Object = {columnIndex:colIndex, rowIndex:rowIndex};
            dg.editedItemPosition = editCell;
        }
      
    </mx:Script>
    <mx:DataGrid id="dg" width="350" height="150" dataProvider="{myAC}" itemEditEnd="onEditEnd(event)" editable="true">
        <mx:columns>
            <mx:DataGridColumn headerText="Name" dataField="name" />
            <mx:DataGridColumn headerText="EMail" dataField="email" />
        </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.Show an event listener for itemEditEnd event using column index, row index, and value propertiesShow an event listener for itemEditEnd event using column index, row index, and value properties
8.Inline CheckBox Editor With OffsetsInline CheckBox Editor With Offsets
9.Returning data from an item editorReturning data from an item editor
10.Use mx.controls.NumericStepper as DataGridColumn editorUse mx.controls.NumericStepper as DataGridColumn editor
11.use to define an inline item editoruse <mx:Component> to define an inline item editor
12.inline item editor contains a single control that supports the data propertyinline item editor contains a single control that supports the data property
13.DataGrid Dropin Editor
14.Inline DataGrid EditorInline DataGrid Editor
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