ExtJS 4.0 - Class system, object inheritance and config
Recently we've started using the new Ext-JS 4.0 class system.
one of the obstacles I came across with was using the configuration while making inheritance.
On most of the examples in the web - it works seamlessly perfect.
but what happens when you try to extend an existing object?
for example, 'Ext.panel.Panel' ?
Suddenly - weird stuff happens and it doesn't work any longer.
So for example:
will give an error.
took me an hour to figure it out - but I found the solution and it's REALLY simple.
It's all about the constructor:
instead of that code, use:
and kaboom - works like a charm :)
Liad
one of the obstacles I came across with was using the configuration while making inheritance.
On most of the examples in the web - it works seamlessly perfect.
but what happens when you try to extend an existing object?
for example, 'Ext.panel.Panel' ?
Suddenly - weird stuff happens and it doesn't work any longer.
So for example:
Ext.define('ProductionMap.popup.serverExplorer', {
extend: 'Ext.panel.Panel',
config: {
ParameterConfig: '',
},
constructor: function (cfg) {
this.initConfig(config);
return this;
},
initComponent: function () {
...
}
will give an error.
took me an hour to figure it out - but I found the solution and it's REALLY simple.
It's all about the constructor:
instead of that code, use:
constructor: function (cfg) {
this.initConfig(config);
this.callParent([config]);
return this;
},
and kaboom - works like a charm :)
Liad
Comments