PDA

View Full Version : defining a config or method to be inherited to a subclass.



coriolis
25 Aug 2011, 7:54 PM
Hi All,

I have a subclass of Ext.panel.Panel and I want to add configs and methods so they can be inherited be subclasses of my class.

What I want is for the getParentUIComponent, getContainingUIComponent, xxxClass and xxyClass methods to be inherited to my subclasses.



Ext.define('CSuper', {
extend: 'Ext.panel.Panel',

configs : {
parentUIComponent : null,
containingUIComponent : null
},
xxyClass : function() {
return this.addCls.apply(this, arguments);
},
xxxClass : function() {
return this.addCls.apply(this, arguments);
}
})




Ext.define('Canvas', {
extend: 'CSuper',
configs : {
Test : {}
}
})

skirtle
28 Aug 2011, 11:53 PM
xxxClass and xxyClass already are inherited.

Your setters won't work because you've got a typo, it's config not configs. They should be inherited too.

If you want the default values applied you'll also need to use initConfig(), though for your null values you may not care:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Base-method-initConfig

The example given in the docs lays a bit of a trap in that in doesn't mention calling callParent() in the constructor.