Code:
Ext.onReady(function(){
Ext.QuickTips.init();
function createTab(title) {
var store = new Ext.data.JsonStore({
// store configs
autoDestroy: true,
url: 'grid-filter.json',
remoteSort: false,
sortInfo: {
field: 'company',
direction: 'ASC'
},
//storeId: 'myStore',
// reader configs
idProperty: 'id',
root: 'data',
totalProperty: 'total',
fields: [{
name: 'id'
}, {
name: 'company'
}, {
name: 'price',
type: 'float'
}, {
name: 'date',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
}, {
name: 'visible',
type: 'boolean'
}, {
name: 'size'
}]
});
/*var createColModel = function (finish, start) {
var columns = [{
dataIndex: 'id',
header: 'Id',
}, {
dataIndex: 'company',
header: 'Company',
id: 'company',
}, {
dataIndex: 'price',
header: 'Price',
}, {
dataIndex: 'size',
header: 'Size',
}, {
dataIndex: 'date',
header: 'Date',
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
}, {
dataIndex: 'visible',
header: 'Visible',
}];
return new Ext.grid.ColumnModel({
columns: columns.slice(start || 0, finish),
defaults: {
sortable: true
}
});
};
var grid = new Ext.grid.GridPanel({
stateful: true,
stateId: 'grid',
border: false,
store: store,
colModel: createColModel(7),
loadMask: true,
autoExpandColumn: 'company',
listeners: {
render: {
fn: function(){
store.load({
params: {
start: 0,
limit: 50
}
});
}
}
},
bbar: new Ext.PagingToolbar({
store: store,
pageSize: 50,
})
});*/
var tab = {title: title, items: {xtype: 'panel', tbar: new Ext.PagingToolbar({
store: store,
pageSize: 50,
})}, layout: 'fit'};
return tab;
}
function createWindow() {
var win = new Ext.Window({
title: 'Grid Filters Example',
height: 400,
width: 700,
layout: 'fit',
items: {
xtype: 'tabpanel',
activeTab: 0,
items: [createTab('tab1'), createTab('tab2')]
}
}).show();
}
var button = new Ext.Button({
text: 'Show Window',
handler: function() {
createWindow();
},
renderTo: Ext.getBody()
});
createWindow();
});
If you click on both tabs, close the window, and then type in firebug console:
Code:
Ext.override(Ext.Panel, {
beforeDestroy: function() {
if(this.header){
this.header.removeAllListeners();
if(this.headerAsText){
Ext.Element.uncache(this.header.child('span'));
}
}
Ext.Element.uncache(
this.header,
this.tbar,
this.bbar,
this.footer,
this.body,
this.bwrap
);
if(this.tools){
for(var k in this.tools){
Ext.destroy(this.tools[k]);
}
}
if(this.buttons){
for(var b in this.buttons){
Ext.destroy(this.buttons[b]);
}
}
if(this.rendered) {
Ext.destroy(this.toolbars);
} else {
Ext.destroy(this.tbar);
Ext.destroy(this.bbar);
}
Ext.Panel.superclass.beforeDestroy.call(this);
}
});
But it didn't work, I don't know why tbar and bbar are undefined for the un rendered panel... Besides I don't know if any of the other properties will have the same problem.