PDA

View Full Version : how to have a dynamic extend?



ttbgwt
28 Aug 2012, 4:00 AM
I have a component that needs to be extended from either a menu item or a button, depending on where that component is used in my app (in a menu vs a toolbar). Is there a way to do this? The below code didnt work...



Ext.define('MYAPP.view.Import', {


extend: this.extendMenuItem ? 'Ext.menu.Item' : 'Ext.button.Button',


initComponent: function () {




Ext.create('MYAPP.view.Import', {
extendMenuItem: true
}),

Zdeno
28 Aug 2012, 4:27 AM
Isnt better create two components instead testing if you will extend from Item or Button? In other case i dont think you can do that because extend is registered preprocessor.

http://edspencer.net/2011/01/ext-js-4-the-class-definition-pipeline.html