PDA

View Full Version : Can a single FormPanel be used in two or more TabPanels at a time



poojagarg89
31 Oct 2012, 2:36 AM
Hi,

I wanna do something like one FormPanel and two Tabs using that same Panel...............Can it be done???



ex:


var form = new Ext.form.FormPanel({
items:[{
xtype:"combo",
id:"id_1"
},{
xtype:"combo",
id:"id_2"
},{
xtype:"button",
text:"save",
handler: function(){
if(tab1){
alert("Save TAB_1 values");
}else{
alert("Save TAB_2 values");
}
}
}]
});

var tabpanel = new NoSwitchTabPanel({
items:[{
id:'tab_1',
title: 'TAB_1',
layout:'fit',
region:'center',
hideMode:'offsets',
items:[form] // Using same FormPanel in tab_1
},{
id:'tab_2',
title: 'TAB_2',
layout:'fit',
region:'center',
hideMode:'offsets',
items:[form] // Using same FormPanel in tab_2
}]
});




as I applied this code it gave me like "form" was not seen in TAB_1 but was visible in TAB_2 or should be said it rendered in the 2nd Tab but not in Tab 1

Or
Is there another way to do the same n the FormPanel is not a popup it is placed on the center region of border Layout

Thanks n Regards,
Pooja ;)

willigogs
31 Oct 2012, 3:11 AM
Just add multiple instances of the same form - but you will have to remove all IDs from any components/elements for this to work without causing errors.

poojagarg89
31 Oct 2012, 4:10 AM
multiple instances like????
I mean what I need to do for making multiple instances of this form can u give small example ??

willigogs
31 Oct 2012, 4:26 AM
Here's an example of adding multiple instances of the same form to a tabpanel:
http://jsfiddle.net/Whinters/jzT3p/

poojagarg89
31 Oct 2012, 4:34 AM
Thanks willigogs :)
well this code is in ExtJs 4.1 and MVC model is applied to this
I'll try converting /using same code in ExtJs 3.4 as my full app. is in extjs3.4

:)

willigogs
31 Oct 2012, 4:36 AM
This is EXTJS 3.4 code :)

(Notice the scripts being called in the top left panel)

poojagarg89
31 Oct 2012, 4:39 AM
oopz sorry.....................will use same code :D