PDA

View Full Version : Multiple instances of GridPanel, strange behaviour of stores



pscholze
28 Jan 2008, 4:53 AM
Hi all,

in my application, for each search I add one new GridPanel instance with results to a TabPanel (please see code below). But everytime I add new GridPanel, ALL stores reload with the params of the one I last added. Any ideas about what I'm doing wrong ?

Thanks in advance,
Peter


quickSearchPanel.on('findPerson',function(obj){

var panel = new de.naxos.appgentest.PersonPanel(obj);
this.insert(0,panel);

this.doLayout();
},mainPanel);


Ext.namespace('de.naxos.appgentest');

de.naxos.appgentest.PersonListPanel = function(params, config) {
de.naxos.appgentest.PersonListPanel.superclass.constructor.call(this, config);

this.store.baseParams = params;
};

Ext.extend(de.naxos.appgentest.PersonListPanel, Ext.grid.GridPanel,{
title: 'Search Results',
region:'north',
layout:'fit',
store : new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'service/person'
}),
reader: new Ext.data.JsonReader({
root: 'data',
id: 'id',
totalProperty: 'totalCount'
}, [ {name: 'id',mapping: 'id'},
{name: 'lastName',mapping: 'lastName'},
{name: 'firstName',mapping: 'firstName'},
{name: 'age',mapping: 'age'}
])
}),
columns: [
{id: 'lastName', header: "Last Name", width: 200, dataIndex: 'lastName'},
{id: 'firstName', header: "First Name", width: 100, dataIndex: 'firstName'},
{id: 'age', header: "Age", width: 45, dataIndex: 'age'}
]
});

de.naxos.appgentest.PersonDetailPanel = function(config) {
de.naxos.appgentest.PersonDetailPanel.superclass.constructor.call(this, config);

this.add({
fieldLabel: 'First Name',
name: 'firstName',
width: 200,
allowBlank:false
});

this.add({
fieldLabel: 'Last Name',
name: 'lastName',
width: 200,
allowBlank:false
});

this.add({
fieldLabel: 'Age',
name: 'age',
width: 25,
allowBlank:false
});

};

Ext.extend(de.naxos.appgentest.PersonDetailPanel, Ext.form.FormPanel,{
region:'center',
split: true,
labelWidth: 75,
labelAlign: 'top',
buttonAlign:'right',
frame:false,
title: 'Person',
bodyStyle:'padding:5px 5px 0',
height: 200,
defaults: { width: 200,
labelStyle:'font-size: 0.75em;',
labelSeparator:''
},
defaultType: 'textfield',
method: 'POST',

loadData: function(id){
this.load({url:'service/person/action/findPersonById',params:{id:id}});
}

});

de.naxos.appgentest.PersonPanel = function(params, config) {
de.naxos.appgentest.PersonPanel.superclass.constructor.call(this, config);

this.resultPanel = new de.naxos.appgentest.PersonListPanel(params);
this.detailPanel = new de.naxos.appgentest.PersonDetailPanel();

this.add(this.resultPanel);
this.add(this.detailPanel);

this.resultPanel.getSelectionModel().on('rowselect',
function(selectionModel, rowindex){
var selId = this.resultPanel.getStore().getAt(rowindex).get('id');
this.detailPanel.load({url:'service/person/action/findPersonById',params:{id:selId}});
},
this);

this.resultPanel.store.on('beforeload',function(store, parms){
alert('Store: '+store.storeId);
}, this);

this.resultPanel.store.proxy.on('beforeload',function(proxy, parms){
alert('Proxy');
}, this);

this.resultPanel.store.load();

};

Ext.extend(de.naxos.appgentest.PersonPanel, Ext.Panel,{
title: 'Person',
layout:'border',
resultPanel: null,
detailPanel: null
});