PDA

View Full Version : How to configure HTTP POST for json store



Vaevictus
6 Aug 2010, 7:05 AM
Is it or will it be possible to configure the jsonstore to load data using HTTP POST? At the moment you are limited to using GET and have to update the class file by hand, which of course is overwritten every time you export.

Thanks,
Vae

jarrednicholls
6 Aug 2010, 7:22 AM
Hi Vaevictus,

"method" is not a configuration option for any Store, including JsonStore. To enforce a POST right now, you have two options:

1) You can set a baseParams value for your JsonStore. When params are defined, the default method becomes POST instead of GET. So you can just type in "{dopost:1}" into the baseParams config, and you have a POST now.

2) You can explicitly set your proxy configuration when instantiating your JsonStore class:


new MyStore({
proxy: new Ext.data.HttpProxy({
url: '/myPostAction',
method: 'POST'
})
});


With that said (and to answer your question if it "will" be possible), we're making improvements to the Designer to allow you to customize a Store from scratch...you'll be able to configure your reader, writer, and proxy/connection in detail, rather than using one of the canned Stores e.g. JsonStore.

Hope that helps!

Vaevictus
6 Aug 2010, 7:35 AM
excellent, thanks for your fast response

julienbouetard
10 Aug 2010, 12:07 AM
Hi,

Where can I type the info of the proxy in the JsonStore ?

cheers

Julien

julienbouetard
10 Aug 2010, 12:23 AM
My code is as follow and I would like to replace the url part by :

proxy : new Ext.data.HttpProxy({url : '../../oneoff/new/oneOffDropDownPopulation.html?actionType=getStrucTypeCode'}),


companyCodeStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
companyCodeStore.superclass.constructor.call(this, Ext.apply({
storeId: 'companyCodeRoot',
url: 'http://localhost/crws/smvc/oneoff/new/oneOffDropDownPopulation.html?actionType=getStrucTypeCode',
root: 'companyCodeRoot',
totalProperty: 'results',
autoLoad: true,
sortField: 'value1',
fields: [
{
name: 'value1'
}
]
}, cfg));
}
});
new companyCodeStore();

jarrednicholls
10 Aug 2010, 6:38 AM
Hi Julien,

You would configure the proxy manually at the time you instantiate the store. Knowing that your store class is overwritten on re-export, I would make a copy of the file/code and use that in your project instead. You can then supply the configuration in the instantiation/construction of your store, and "x" or delete the url configuration. We're going to make it a project preference to not instantiate your stores in the near future.

Thanks.

julienbouetard
10 Aug 2010, 3:50 PM
HI Jarred, thanks for your quick clarification. :-)

looking forward to the new release, any time range for that change ?

cheers

Julien

DrZog
22 Oct 2010, 11:00 AM
+1 for me. The work around works but would be nice if native as breaks Codeigniter out of the box. Having said that I think Ext Designer is awesome!