PDA

View Full Version : extended Grid gives this.ds is undefined



jsemmanuel
22 Dec 2009, 4:34 AM
I have the following code extended gridpanel which I am using as a panel in a tabpanel

However, I get this error in firebug
this.ds is undefined
http://localhost/xapads-new/extjs/ext-all-debug.js
Line 63373
var state = this.ds.getSortState();\n

Am I missing to set some property?



Ext.namespace("Ext.ux.cs");

Ext.ux.cs.cs=Ext.extend(Ext.grid.GridPanel,{
initComponent:function(){
Ext.apply(this, {
title:'Statistics',
store: this.StatisticsStore,
height:PAGE_HEIGHT-63,
loadMask:true,
cm:new Ext.grid.ColumnModel({
columns:[
{name:'day',header:'Date', dataIndex:'day', summaryRenderer:function(){return 'Totals';}},
]
}),
sm: new Ext.grid.RowSelectionModel({
singleSelect:true
}),
viewConfig: {
forceFit:true,
emptyText: 'No statistics available for the selected campaign/period.'
}

})
Ext.ux.cs.cs.superclass.initComponent.call(this);

this.StatisticsStore=new Ext.data.JsonStore({
url:PHP_AJAX_URL + '/advertiser_statistics.php',
baseParams:{task:'list_all_statistics'},
root:'campaigns',
totalRecords:'results',
fields:['cid','day'],
autoLoad:true
});

}
})

I am creating the tab panel like this.

function LoadControlPanel(){

Ext.QuickTips.init();

//The tab panel
var main_body = new Ext.TabPanel ({
id: 'content-panel',
region: 'center',
margins: '2 5 5 5',
activeTab: 0,
enableTabScroll: true,
resizeTabs:true,
border: false,
items:[

new Ext.ux.Xapads.Advertiser.Campaigns.StatisticsTab(),

]
});

//render the tabpanel to the entire browser window.
new Ext.Viewport({
layout: 'border',
title: 'Ext Layout Browser',
items: [{
xtype: 'box',
region: 'north',
applyTo: 'header',
height: 30
},
main_body
],
renderTo: Ext.getBody()
});

}

22 Dec 2009, 4:54 AM
this.StatisticsStore does not exist when you call Ext.apply. Elevate it *above* the the call of Ext.apply.


That said, why are you setting up a local reference to the store? Upon destruction, you should set that reference to null.

jsemmanuel
22 Dec 2009, 5:02 AM
jgarcia. Thanks. that solved the error. As for the local reference to store, I used it since later, on clicking a button, the store is loaded with different parameters, but yes, I guess, a call to the gridpanel's getStore() would be better. Or were you suggesting some other way?

22 Dec 2009, 5:05 AM
Ext.apply(this, {some object}) applys those properties to this.

Hence, this.store will exist after the call to Ext.apply

22 Dec 2009, 5:19 AM
Btw, CH15 of my book explains the ins-and-outs of extensions and plugins :)

jsemmanuel
22 Dec 2009, 5:49 AM
I did go out looking for your book in India after looking up the places where it was available. :) Unfortunately it was a Sunday and shops were closed.

I think, I will order it online today.

Thanks again for your help.

22 Dec 2009, 8:19 AM
It's not printed yet, but an early edition of the ebook is available.