Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How can I undo the changes made after an EditCompleteEvent ?

    Hello,

    Sometimes I need to undo the row edit changes on a ListGrid. How can I do that?

    I've tried several ideas but I had no luck:

    Code:
    grid.addEditCompleteHandler(new EditCompleteHandler() {
    	public void onEditComplete(EditCompleteEvent event) {
    
    		if( someCondition ) {
    
    			ListGridRecord newRecord = grid.getRecord( event.getRowNum() );
    			ListGridRecord oldRecord = event.getOldRecord();
    
    			// This method doesn't undo the changes
    			grid.discardAllEdits(
    				new int[]{event.getRowNum()}, false);
    
    			// This doesn't undo the changes either
    			newRecord.setAttribute( SOME_ATTRIBUTE,
    				oldRecord.getAttribute( SOME_ATTRIBUTE ));
    
    			// This method doesn't exist but could be useful
    			event.undoEdit();
    		}
    	}
    }
    Using SmartGWT 2.5 on IE 8

    Thanks!

    #2
    EditComplete fires after the changes have been saved to the server so that's too late. If you did discardEdits() in a different event (such as EditorExit) it would work.

    Comment


      #3
      Thanks Iso, but EditorExit fires every time I exit a field and not just when I exit the row.

      The user can edit several columns in a row but when he wants to "commit" the changes I would like to undo them if they are wrong (and I don't know whether they are wrong until he finishes editing the entire row).

      Comment


        #4
        Any idea? How can I undo the changes to the whole row?

        Comment


          #5
          You can't undo saved changes, the grid has stopped tracking them. You have to do it on an earlier event like EditorExit, even if it fires more than once.

          Comment

          Working...
          X