PDA

View Full Version : how to destroy the panel dynamically in extjs



gokulpotluri
16 Jul 2013, 12:58 AM
Hi,
I am creating a panel with an id which is based on a flag


var that = this;
alert(1 + ", " + that.isClone + ", " + recordId)
var panelID = this.entityType + this.wfContext + recordId;
if(that.isClone)
panelID = this.entityType + this.wfContext + recordId + '_clone';
alert(2 + ", " + panelID)
this.panel = new Ext.Panel({
id : panelID,
title : 'Loading...',
layout: 'fit',
border: false,
autoScroll : true,
closable: true,
bodyStyle: {
'padding': '0px',
'background': '#FFFFFF',
'overflow-x': 'hidden'
},
getRequestObject : function(){
return that;
}
});


And i am trying to delete this panel(this.panel) in some other function which is in the same class



onSubmit : function(recordId){
alert(1 + ", " + this.panel + ", " + this.panel.id)
this.panel.destroy();
alert(2)
new sd.openRequest({
entityType : this.entityType,
wfContext : this.wfContext,
recordId : recordId,
aftercreate : this.aftercreate
});
}

but it is giving js error called 'Style' is null or not an object at the line this.panel.destroy(); after alert(1) in onSubmit function. Even alert(2) is not getting rendered.

Advance thanks for help.

Farish
16 Jul 2013, 2:30 AM
if you are assigning an id to your panel, you can try using:


Ext.getCmp(this.panel.id).destroy();