PDA

View Full Version : Destroy and recreate a tabpanel



pitviper202002
26 Aug 2009, 12:48 AM
Hi,

i am able to destroy a tabpanel on tree node click but not able to recreate it.Please help

regards,
viper

pitviper202002
26 Aug 2009, 2:07 AM
Still not able to recreate the tabpanel once i destroy it ,plzzz guide me

Condor
26 Aug 2009, 2:13 AM
How are you creating and destroying the tabpanel?

pitviper202002
26 Aug 2009, 2:29 AM
to create the tabpanel i call this function on click of one tree node

function createNewProject() {
var tabs = new Ext.TabPanel({
renderTo : 'centerpanel',
id : 'newProjectPanel',
hidden : true,
buttonAlign : 'center',
buttons : [{
text : 'Save',
id : 'save',
iconCls : 'save'
}, {
text : 'Reset',
iconCls : 'reset'
}, {
text : 'Close',
iconCls : 'close'
}],
activeTab : 0,
items : [new Ext.form.FormPanel({
title : 'Basic',
id : 'basicPanel',
items : []
}), new Ext.form.FormPanel({
id : 'financialPanel',
title : 'Financial',
height : 435,
frame : true
}), new Ext.form.FormPanel({
title : 'Technical',
id : 'technicalPanel',
items : []
}), new Ext.form.FormPanel({
id : 'proceedingsPanel',
title : 'Proceedings'
})]
});
}

and to destroy it i call Ext.getCmp('newProjectPanel').destroy(); from another tree node

Animal
26 Aug 2009, 2:29 AM
A TabPanel containing one FormPanel which contains nothing but FormPanels?

Freaky.

pitviper202002
26 Aug 2009, 2:35 AM
plzzzzzzzzzz help me how to recreate this once i have destroyed it

why is the tabpanel not created and rendered when the function is called again

pitviper202002
26 Aug 2009, 3:06 AM
:(( please help

pitviper202002
26 Aug 2009, 5:57 AM
Please could anyone help me with this.Have been trying but not able to succeed

Jack9
26 Aug 2009, 3:16 PM
tabs.setVisible(false);
tabs.setVisible(true);

or alternately,
var MyParent = tabs.findParentByType('panel'); MyParent.remove(tabs); MyParent.doLayout();
MyParent.add(tabs); MyParent.doLayout();

pitviper202002
26 Aug 2009, 8:14 PM
Thanks Jack that worked but cant we recreate the tab panel once we destroy it.

regards,
viper

Condor
26 Aug 2009, 10:25 PM
You should be able to recreate it!

What exactly doesn't work when you recreate the tabpanel?

Also, destroying the tabpanel will also destroy all the components you added to the formpanels. You'll have to recreate those as well.

Jack9
27 Aug 2009, 9:27 AM
Here we go, the code cleaned up in a test case:

Ext.onReady(function(){
function createNewProject() {
var tabs = new Ext.TabPanel({
renderTo : 'centerpanel',
id : 'newProjectPanel',
hidden : true,
buttonAlign : 'center',
buttons : [
{
text : 'Save',
id : 'save',
iconCls : 'save'
}, {
text : 'Reset',
iconCls : 'reset'
}, {
text : 'Close',
iconCls : 'close'
}
],
activeTab : 0,
items : [
new Ext.form.FormPanel({
title : 'Basic',
id : 'basicPanel',
items : []
}),
new Ext.form.FormPanel({
id : 'financialPanel',
title : 'Financial',
height : 435,
frame : true
}),
new Ext.form.FormPanel({
title : 'Technical',
id : 'technicalPanel',
items : []
}),
new Ext.form.FormPanel({
id : 'proceedingsPanel',
title : 'Proceedings'
})
]
});
tabs.setVisible(true); // Lets see what we're lookin at, you set it hidden by default!
}
createNewProject();
Ext.getCmp('newProjectPanel').destroy();
createNewProject();
Ext.getCmp('newProjectPanel').destroy();
createNewProject();
});Yup. That gives us the correct result, as we would expect. I am not sure you're telling us the whole story!