View Full Version : Adding config to a subclass
Gummy
24 Nov 2011, 1:09 AM
According to this thread http://www.sencha.com/forum/showthread.php?133653-Unable-to-subclass-and-use-panels, you can't use initConfig in the constructor of a subclass.
So you can't do this:
Ext.define('My.Window', {
extend: 'Ext.window.Window'
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.callParent(arguments);
this.initConfig(config);
}
});
How to you add a config to a subclass then ?
tvanzoelen
24 Nov 2011, 6:32 AM
Ext.define('My.Window', {
extend: 'Ext.Window',
initComponent: function() {
Ext.apply(this, {
name: 'Awesome',
isAwesome: true
});
My.Window.superclass.initComponent.apply(this, arguments);
},
constructor: function(config) {
this.callParent(arguments);
this.initConfig(config);
}
});
Taken from http://www.sencha.com/blog/countdown-to-ext-js-4-dynamic-loading-and-new-class-system
Or you pass the config in the constructor
Gummy
24 Nov 2011, 8:48 PM
Taken from http://www.sencha.com/blog/countdown-to-ext-js-4-dynamic-loading-and-new-class-system
Or you pass the config in the constructor
I don't think Ext.apply can add new configs and create the getters and setters, it just sets the value of existing configs.
I do pass the config in the constructor, but according to the thread I linked it's not good to call initConfig() in it.
tvanzoelen
25 Nov 2011, 12:28 AM
initConfig is not needed. Below should work.
Ext.define('My.Window', {
extend: 'Ext.Window',
initComponent: function() {
this.name: 'Awesome';
this.isAwesome: true;
return this.callParent();
},
constructor: function(config) {
return this.callParent(arguments);
}
});
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.