PDA

View Full Version : Tab Closes Once but Not Twice



adbox
5 Mar 2009, 8:44 AM
See Post 9

5 Mar 2009, 8:51 AM
how are you creating your tabs?? Please post your code in code tags.

adbox
5 Mar 2009, 12:27 PM
see post 9

adbox
5 Mar 2009, 2:51 PM
Ive been studying the behavior and it works like this: Open into tab, it creates everything well. Close it. It closes everything. I open it again, and it opens everything well, but this time when I close the tab, it flags an error saying: this.field is null and this.field.destroy(); , while at the same time destroying everything but the two text area boxes of the last open tab, and the actual tab is still open too, and from that point on cannot be closed.

mjlecomte
5 Mar 2009, 3:16 PM
I didn't sift through all that code. But one way you can easily check if things are being destroyed is to inspect the DOM for Ext.ComponentMgr. It has a property all. You can inspect that property before and after you add the tab, and then before and after you destroy it. If you see the item count increase, you know you've got a leak somewhere. If you're leaking components that have an id (which should be unique on the page), you'll surely have problems.

If it were me I would test and post with a smaller proof case. You'll scare off most people from helping when you post too much code like that.

adbox
5 Mar 2009, 4:31 PM
I didn't sift through all that code. But one way you can easily check if things are being destroyed is to inspect the DOM for Ext.ComponentMgr. It has a property all. You can inspect that property before and after you add the tab, and then before and after you destroy it. If you see the item count increase, you know you've got a leak somewhere. If you're leaking components that have an id (which should be unique on the page), you'll surely have problems.

If it were me I would test and post with a smaller proof case. You'll scare off most people from helping when you post too much code like that.


Thanks for the advice, I'll play with this awhile and see if i can clear up my leaks.

adbox
5 Mar 2009, 4:49 PM
see post 9

mjlecomte
5 Mar 2009, 4:58 PM
I don't see anything in that function that even creates components. Can you post screenshots of firebug showing Ext.ComponentMrg.all before and after the function call? Or just do:

console.log("count: ",Ext.ComponentMgr.all.length);

adbox
6 Mar 2009, 9:07 AM
Updated Code:


function f_bopp_quotes_openRecord(){
var GRID_BOPP_QUOTES = Ext.getCmp('id_grid_bopp_quotes');
var selection = GRID_BOPP_QUOTES.selModel.getSelections();

//SET-UP ARRY TO OPEN RECORD(S)
if (GRID_BOPP_QUOTES.selModel.getCount()==1)
{
var selects = []; selects.push(selection[0].json.id); var selects_array = Ext.encode(selects);
DS_BOPP_QUOTES_2.baseParams = { task: 'OPENRECORD', selects: selects_array };
DS_BOPP_QUOTES_2.load();
DS_BOPP_QUOTES_3.baseParams = {task: 'LINEITEMS',selects: selects_array };
DS_BOPP_QUOTES_3.load();
DS_BOPP_QUOTES_2.on('load', function(){


/////////////SET OPEN QUOTE INTO TAB WINDOW
Ext.getCmp('tabs_default').insert(0,{
id: 'id_tab_bopp_open_quote',
title: DS_BOPP_QUOTES_2.collect('company_name'),
listeners: {activate: f_quoteSwitch},
layout:'fit', border:false, closable:true,
items: {
labelAlign:'top', labelWidth: 75,
layout:'table', id: 'id_bopp_quotes_table',
layoutConfig: {columns: 3, valign:top},
bodyStyle: 'padding-left:5px; width:90%;
text-align:center;padding-left:20px;padding-right:40px;padding-bottom:5px;
padding-top:20px;',
autoScroll: true,
//autoWidth:true,
defaults: { valign:'top'},
items: [{
title:'Customer Information',
layout:'form',
colspan:1,
autoWidth:true,
rowspan:1,
bodyStyle: 'padding-left:10px; width:100%;
text-align:left;padding-top:10px;padding-bottom:10px;padding-right:10px; ',
items: [
{xtype:'textfield',fieldLabel: 'First Name',name: 'first_name',
width: 50,autoWidth:true,anchor:'95%',value: DS_BOPP_QUOTES_2.collect('first_name')},
],
},
{

title:'Line Items',
xtype:'editorgrid',
id:'id_bopp_quotes_lineitems',
colspan: 3, rowspan: 1, bodyStyle: 'text-align:center;padding:0px;', height:300,
store: DS_BOPP_QUOTES_3,
cm: CM_BOPP_QUOTES_2,
enableColLock:false, autoExpandColumn: 'service_description',
clicksToEdit:1,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
}
}],
buttons: [
{
text:'Send Quote',
handler: f_send,
},
{
text: 'Save',
handler: f_save,
},
{
text: 'Print',
handler: f_bopp_quotes_print,
},
{
text: 'Close',
handler: f_close
}],
});


//set active tab
Ext.getCmp('tabs_default').setActiveTab('id_tab_bopp_open_quote');
},false,{single: true} );//end function unique()

}//end if rows selected is equal to one
}//end f_open()
The Screen Shots work like this:

ss1
items open: 56
This screen shot is my main grid where I will open records into a new tab... one at a time for now.

ss2
items open: 98
I've opened one record

ss3
items: 45
I've closed the record/tab
ss4
items:90
I've reopened the same record.
ss5
items: 56
I've attempted to close the record. All fields were destroyed except my two comment boxes. The tab will not close.

ss6
firefox errors

adbox
6 Mar 2009, 9:07 AM
ss6

adbox
6 Mar 2009, 5:16 PM
I narrowed the problem down to the editorgrid. The tabs close correctly if the editor grid is not included in them.

If I even comment out
xtype:'editorgrid',
.. then the tabs close correctly.

Is this a bug?

Condor
7 Mar 2009, 12:59 AM
Are you sure you don't have any duplicate ids on your page?

adbox
7 Mar 2009, 10:50 PM
yes. the problem only happens if an item is declared as an xtype: 'editorgrid'. If I change the xtype to 'grid', then the tabs close normally.

adbox
7 Mar 2009, 11:14 PM
I searched the bug's section and found a similar topic.... seems the editors of the editor grid aren't destroyed properly in the 2.x version.... this fixes the problem.




Ext.override(Ext.Editor, {
beforeDestroy : function(){
Ext.destroy(this.field);
this.field = null;
}
});



whew!