PDA

View Full Version : Accessing Values for Store inside Extended Grid Panel



msuresh
25 Nov 2010, 9:35 PM
Hi,
I am extending a grid panel and passing dataURL and fields to the store and the JSON reader. However I am unable to access those parameters inside store or JSON reader.

Am I doing something wrong or do we need to extend store and JSON reader too?



SearchGridPanel = Ext.extend(Ext.grid.GridPanel, {
frame: false,
stripeRows : true,
autoScroll:true,
dataURL:'/data/json/search/searchVal.json',
...
...
dataFields:[
'id', {name:'gdate', type: 'date'},
'model', 'sn', 'sysid', 'caseNumber', 'system',
'release','title'
],
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: this.dataURL, //Is not loading
method: 'POST',
autoLoad:true
}),
reader: new Ext.data.JsonReader({
root: 'rows',
idProperty:'id',
totalProperty: 'totalCount',
fields: this.dataFields //Is not loading
}),
...
...
...


Regards,
SURESH KUMAR M R

msuresh
25 Nov 2010, 10:07 PM
Sorry, calling those now inside initcomponent in config={};

autoLoad will not work before apply... so the store needs to be initialized...



initComponent:function() {
// mask the grid if there is no data if so configured

var config={
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/data/json/search/searchVal.json',
method: 'POST'
//autoLoad:true
}),
reader: new Ext.data.JsonReader({
root: 'rows',
idProperty:'id',
totalProperty: 'totalCount',
fields: this.dataFields
}),
sortInfo: {
field:'gdate',
direction: 'DESC'
},
listeners: {
loadexception: {
fn: function(proxy, options, response, e){
var showMask=false;
Ext.MessageBox.show({
title: 'UTP Error',
msg: 'Unable to load the data...',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
})
}
},
scope: this
}
})

};
Ext.apply(this, config);
SearchGridPanel.superclass.initComponent.apply(this, arguments);
this.store.load();