i've modified my example to give me what i'm trying to achieve but its very ugly.
[btw. i'm trying this approach because i should be able to do more sophisticated validations (asynchronous ones)..... without losing focus from the existing cell.] public function validateMe(event:DataGridEvent):void { var newData:String= TextInput(myGrid.itemEditorInstance).text; if(newData == "") { TextInput(myGrid.itemEditorInstance).errorString = "ERROR"; } else { // update dataprovider var record:Object=IList(myGrid.dataProvider).getItemAt(e.rowIndex); record[e.dataField] = TextInput(myGrid.itemEditorInstance).text; IList(myGrid.dataProvider).setItemAt(record, e.rowIndex); //destroy editor and setfocus to next cell myGrid.destroyItemEditor(); myGrid.editedItemPosition = {columnIndex:e.columnIndex+1, rowIndex:e.rowIndex}; } } --- In flexcoders@yahoogroups.com, "bhaq1972" <[EMAIL PROTECTED]> wrote: > > Hi everyone, > i'm trying a modified docs datgrid example where i call > event.preventDefault() first, and then do the validation (example > below). > > If the validation fails i show the errorString otherwise i want to > continue. > > How do i cancel the event.preventDefault() (if that makes sense) > > regrds > bod > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> > > <mx:Script> > <![CDATA[ > > import mx.controls.TextInput; > import mx.events.*; > > [Bindable] > public var initDG:Array = [{Company: 'Acme', Contact: 'Bob Jones', > Phone: '413-555-1212', City: 'Boston', State: 'MA'}, > {Company: 'Allied', Contact: 'Jane Smith', Phone: '617-555-3434', > City: 'SanFrancisco', State: 'CA'} ]; > > public function validateData(event:DataGridEvent):void > { > event.preventDefault(); > > validateMe(event); > } > > public function validateMe(event:DataGridEvent):void > { > var newData:String= TextInput(myGrid.itemEditorInstance).text; > if(newData == "") > { > TextInput(myGrid.itemEditorInstance).errorString = "ERROR"; > } > else > { > // How do i cancel original preventDefault(); > } > } > ]]> > </mx:Script> > > <mx:DataGrid id="myGrid" dataProvider="{initDG}" editable="true" > itemEditEnd="validateData(event)"> > <mx:columns> > <mx:DataGridColumn dataField="Company" editable="false"/> > <mx:DataGridColumn dataField="Contact"/> > <mx:DataGridColumn dataField="Phone"/> > <mx:DataGridColumn dataField="City"/> > <mx:DataGridColumn dataField="State"/> > </mx:columns> > </mx:DataGrid> > </mx:Application> > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/