Reputation: 9809
Ext.define('RevenuePanel', { extend: 'Ext.panel.Panel',
items: [
..........
Ext.create('Ext.button.Button', {text: 'Button'}) ]
});
In this case,I believe the items property is copied to the class's prototype.
What is the good programming practice/s to allow the panel to have custom behaviour for its items at multiple containers which would use it within the application?
We are on Ext3.4x
Upvotes: 0
Views: 43
Reputation: 23973
I assume that you just want to add more items, without overriding the predefined.
Ext.define('RevenuePanel', {
extend: 'Ext.panel.Panel',
initComponent: function(){
var me = this,
newItems = me.items,
defaultItems, items;
// apply your default items
defaultItems = [{xtype:'button', text:'Button'}];
// check if there are new items defined for this instance
if(typeof newItems != 'undefined') {
items = defaultItems.concat((newItems instanceof Array ) ? newItems : [newItems]);
} else {
items = defaultItems;
}
// override the items
me.items = items;
me.callParent(arguments);
}
});
Upvotes: 2