PDA

View Full Version : How to use 1 http request with multiple combobox



metfan
4 Dec 2009, 7:28 AM
Hello,

First sorry for my bad english (I'm french :(().

I replace ExtJs 2 in my app by ExtJs3 and try some optimisation.
I have a form with 8 combobox.
Each combobox have his own store and when I refresh my form I obtain 8 http request.

Because I use mode: 'local' in comboBox definition I would like reduce 8 http request to only 1.

My responses was:

{ statutimports: [
{id:'1', name:'Créé', css:'1'},
{id:'2', name:'Public', css:'1'}
]}
{ level: [
{id:'1', name:'Cannister', css:'1'},
{id:'2', name:'ECE/Japan', css:'2'}
]}.......

I think I could merge all response in one:

{
statutimports: [
{id:'1', name:'Créé', css:'1'},
{id:'2', name:'Public', css:'1'}
] ,
level: [
{id:'1', name:'Cannister', css:'1'},
{id:'2', name:'ECE/Japan', css:'2'}

]}

I defined 1 store per comboBox.


this.oJsonStore = new Ext.data.Store({
proxy: poProxy,
reader: new Ext.data.JsonReader({
root: psRoot
},[id, name, css])
});

poProxy is the same instance of Ext.data.HttpProxy for all store.
psRoot is a proper root associate to comboBox statutimports & level in my exemple.

Unfortunatly each store submit a http request.

I suppose I need to create a record who contains all my data and a reader for each combobox. But I didn't find how to do this. If someone could help me or say me where I can find example of code.

Thanks

Condor
4 Dec 2009, 8:38 AM
No, you only need to load the second store with the data from the first store, e.g.

store1.on('load', function(){
store2.loadData(store1.reader.jsonData);
});

metfan
7 Dec 2009, 8:39 AM
Thanks to your help., it's working perfect.