PDA

View Full Version : How to pass parameters to inherited custom component?



masm
16 Jan 2012, 5:46 AM
For instance I have following base class:


Ext.define('MyCompany.BaseClass', {
extend: 'Ext.panel.Panel',

// This field I want to initialize
customField: '',

initComponent: function() {
this.callParent(arguments);
}
});

And custom derived class:


Ext.define('MyCompany.SubClass', {
extend: 'MyCompany.BaseClass',

initComponent: function() {
this.callParent(arguments);
}
});

And then I try to create an instance of subclass with passing a parameter to initialize 'customField':


Ext.create('MyCompany.SubClass', {
customField: 'Test'
});

Where is appropriate place to catch passed parameter in the class hierarchy and initialize necessary field?

mitchellsimoens
16 Jan 2012, 10:47 AM
In initComponent you should be able to access your customField via this.customField.

masm
16 Jan 2012, 9:27 PM
I've tried access it via 'arguments', didn't know that it can be accessed directly. Thanks!