PDA

View Full Version : "Multiple" xtypes



karga
30 Aug 2009, 11:06 AM
Hi,

I don't know if there's a solution to this "problem", I'm kinda just looking for a smart way to save me from some coding..

To keep it simple and easy to change similar components, I'm extending some basic components like the Ext.Panel:


Ext.Panel.WestPanel = Ext.extend(Ext.Panel,{
constructor: function(config) {
config = Ext.apply({
region: 'west',
split: true,
collapsible: true,
width: 200
},config)
Ext.Panel.WestPanel.superclass.constructor.call(this,config)
}
})
Ext.reg('westpanel',Ext.Panel.WestPanel)This westpanel could very possible be a treepanel, which it will probably always be.. How could I make the empty westpanel in the following into a treepanel, without hardcoding it into the panel-extension?

new Ext.Viewport({
layout: 'border',
items: [{
xtype: 'westpanel',
title: 'Navigation'
},{
region: 'center',
layout: 'cardlayout',
id: 'mainpanel'
}]
})

madamut
31 Aug 2009, 5:46 AM
I haven't tried this but I think it should work. You can use the "remove" method of the viewport to remove your existing westpanel, then use "add" method with the new component followed by a call to "doLayout".