Results 1 to 6 of 6

Thread: Ext define override

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Spain
    Posts
    77
    Vote Rating
    1
      0  

    Default Ext define override

    When I override a class for example the Spinnerfield I insert this

    Code:
    Ext.define('my.Spinner', {
    Ext.define('iBone.field.Spinner', {
        override: 'Ext.field.Spinner',
    ...
    })
    and I put the functions that I want override, for example applyValue, but inside this method I put
    Code:
    this.callParent([value])
    and it go to the function applyValue of the Ext.field.Spinner and then to the applyValue of the Ext.field.Number, when I want that it go directly to the second option. Because it's supposed I'm overriding this fucntion and the same in the Ext.field.Spinner would cease to exist.

    Am I doing something wrong??

    Sorry for my English, thanks

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

    Default

    You can call the superclass of whatever component via

    Code:
    applyValue : function(newValue, oldValue) {
        return Ext.field.Number.superclass.applyValue.call(this, newValue, oldValue);
    }
    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
    Apr 2011
    Location
    Spain
    Posts
    77
    Vote Rating
    1
      0  

    Default

    Thanks for the reply, I'll try it.

    But it's supposed that the method callParent() do the proper function when it's called from a
    overwritten class or it's a bug and it would go to the superclass of the class overwritten and don't to the parent function of the overwritten class??


    Thanks again.

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

    Default

    You may be needing callOverridden and not callParent, callOverridden !== callParent
    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

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Location
    Spain
    Posts
    77
    Vote Rating
    1
      0  

    Default

    I tried it with callOverridden and callParent from getValue of a class that overrides Ext.field.Number and two functions go to the same place: getValue function of class Ext.field.Number.


    I guess I'll use My.field.Number.superclass.getValue.call(this).


    Thanks

  6. #6
    Ext JS Premium Member smokeman's Avatar
    Join Date
    Jul 2007
    Posts
    475
    Answers
    4
    Vote Rating
    2
      0  

    Default

    how do you know when to use calloverridden, and callparent?

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
  •