PDA

View Full Version : Override config



A.Tyshchyk
24 Oct 2012, 5:01 AM
Is it possible to automatically generate getter and setter after the Class was defined?

For example I want to do like this



Ext.define('Ext.SomeClass.override', {
override: 'Ext.SomeClass',
config: {
newProperty: null
},
applyNewProperty: function() {
}
}

mitchellsimoens
27 Oct 2012, 12:59 AM
Overrides don't accept the config object

A.Tyshchyk
29 Oct 2012, 10:08 AM
I know it. I wonder if it is possible to do such a thing by another way. If it's not, it will be a good if you add such functionality in a new versions.

suzuki1100nz
29 Oct 2012, 10:37 PM
There's a bug logged with the development team regarding the ability to set config during an override.
Handy when you want the new config available to subclass components which you don't get with extends.
There is some debate about whether or not it is a legitimate use of override.

You can get around it by using a mixin which is Senchas mechanism to achieve multiple inheritance.

A.Tyshchyk
30 Oct 2012, 12:44 AM
I'm not exactly understood what you mean. I want to add to config new property. How I could do this without inheritance? Can you show an example?

suzuki1100nz
30 Oct 2012, 10:30 AM
Have a look at the API example -http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Class-cfg-mixins
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Class-cfg-mixins)

Create a mixin class (with the new config and behaviour), add it to the class you want the behavior and config for using the mixins config.

Then where necessary use the config in the mixin by delegating to the mixin object.

A.Tyshchyk
31 Oct 2012, 1:14 AM
I've read that. Good opportunity to multiple inheritance, but it's not what I need.
The problem is that i can't set "mixins" property in override mechanism.
I want to add functionality to sencha's base class Ext.field.Text.

suzuki1100nz
2 Nov 2012, 11:00 AM
RE bug - http://www.sencha.com/forum/showthread.php?187525-Adding-custom-configs-in-class-override-throws-error&p=907047#post907047


(http://www.sencha.com/forum/showthread.php?187525-Adding-custom-configs-in-class-override-throws-error&p=907047#post907047)