PDA

View Full Version : How to remove/delete some property of some class



bugsbunny
6 May 2009, 4:27 PM
Hi all,
I am new to extjs. Please help me . i have a tab panel and within that panel I have a form.

I basically have 2 classes

1) myTabPanel
2) myFormPanel
I have embedded myFormPanel inside myTabPanel.

Now since i want to reuse my classes. i want to have the formPanel to have a predefined title
but I dont want to have it when I use it from tabpanel as tabpanel has one of its own.

below is my sample code

myFormPanel = Ext.extend(Ext.form.FormPanel, {
labelWidth : 75,
frame : false,
defaultType : 'textfield',
title : 'hello',

/*
........


.....

});

myTabPanel = Ext.extend(Ext.TabPanel, {
layout : 'border',
title : 'Create Case',
frame : true,
bodyBorder : false,
form : new myFormPanel(),

initComponent : function() {

this.form.title = null;

//The above line does not help...Basically I want to check if myTabPanel has title I dont want title in the formPanel. But I want to have it in the Class since I may want it to be used somwhere else..Also wat happens when I make it null there is a small line rendered on the top of the form which is annoying


Can someone please help

elishnevsky
6 May 2009, 4:47 PM
Your problem has nothing to do with Ext JS. What you need is is delete operator in JavaScript.

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/delete_Operator

piyushjain7
6 May 2009, 4:56 PM
Pass a config when you create your formPanel something like "inform: true". You can then check that in your formPanel whether you want title or not. So your formPanel code will change like this:


myFormPanel = Ext.extend(Ext.form.FormPanel, {
labelWidth : 75,
frame : false,
defaultType : 'textfield',
// don't add the title here
//title : 'hello',

initComponent: function(){
if(this.inForm){
this.header = false;
}else{
this.title = "hello";
}
// any other default properties you want to apply
Ext.apply(this, {});

}

/*
........


.....

});