Results 1 to 3 of 3

Thread: How to override cancelEdit in Ext.Editor

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    18
    Vote Rating
    0
      0  

    Thumbs up How to override cancelEdit in Ext.Editor

    Dears,
    cancelEdit of Ext.Editor will reset the start value of component, if validation fails. I want to keep the wrong value and give users alert or sth in some scenarios. But I find no place can override this method.
    Actually, I think I need remove them from this method.

    var v = this.getValue();
    this.setValue(this.startValue);
    this.fireEvent("canceledit", this, v, this.startValue);
    Could someone lend me a hand?
    BTW, my ext version is 3.3. And this function is for column editor.
    There is an example I wrote, it dosn't work
    this.editor1 = function(){
    var editor = new Ext.Editor(new Ext.form.TextField({
    maxLength : 5
    }));
    editor.cancelEdit = function(remainVisible){
    if(this.editing){
    this.hideEdit(remainVisible);
    }
    }
    return editor;
    };
    I set this editor to a column. The column still use cancelEdit in ext-all-debug.js

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    If you want to change cancelEdit you can do this easily:

    Code:
    Ext.override(Ext.Editor, {
        cancelEdit : function(remainVisible){
            if(this.editing){
                var v = this.getValue();
                //this.setValue(this.startValue);
                this.hideEdit(remainVisible);
                this.fireEvent("canceledit", this, v, this.startValue);
            }
        }
    });
    As you can see I commented out the setValue which may be of help to you. However, cancelEdit is also used when you press the Esc button so this would affect that as well. Also completeEdit uses it too.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    18
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by mitchellsimoens View Post
    If you want to change cancelEdit you can do this easily:

    Code:
    Ext.override(Ext.Editor, {
        cancelEdit : function(remainVisible){
            if(this.editing){
                var v = this.getValue();
                //this.setValue(this.startValue);
                this.hideEdit(remainVisible);
                this.fireEvent("canceledit", this, v, this.startValue);
            }
        }
    });
    As you can see I commented out the setValue which may be of help to you. However, cancelEdit is also used when you press the Esc button so this would affect that as well. Also completeEdit uses it too.
    It works, but actually I found that I should override completeEdit of Editor.
    I delete code about cancelEdit there.
    Thanks for you kindness!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •