PDA

View Full Version : How to give http post parameter to Ext.data.HttpProxy



mcadirci
22 Feb 2011, 1:19 AM
Hello,

I have a store that I load its data via HttpProxy.

proxyUrl = 'do?op=searchGroupCmd&searchStringJsp='+argText;
var proxy=new Ext.data.HttpProxy( {url:proxyUrl});
Ext.getCmp('searchGrid').store.proxy=proxy;
loadData();

The problem is I have problems with some special chars using http get.

Is there a way of giving Http proxy http post param?

Thanks.

Grolubao
22 Feb 2011, 2:18 AM
Hi!
Sure, no problem at all:



proxy : new Ext.data.HttpProxy({
url : 'get-list-currencies.json',
method : 'POST'
}),

mcadirci
22 Feb 2011, 3:21 AM
Hello,

Thanks for your answer. But I have smt that I can't understand.

At this example where should I put the param names and values?

For example:
get-list-currencies.json?parName=value

Grolubao
22 Feb 2011, 3:47 AM
Well, it depends. If you always want to send the same parameters you can use the baseParams property of the store, if you want to pass diferent parameters you can do so using the store.load() method.

mcadirci
22 Feb 2011, 3:50 AM
Could you please give an example about store.load()? That would greatly help me.

Grolubao
22 Feb 2011, 3:56 AM
Sure, no problem.

Example with baseParams:



var entityData = 2;

var store = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
url: '<c:url value="/getParameters.json"/>',
method: 'GET'
}),
baseParams: {
calculationEntityId: entityData
},
autoLoad : true,
fields: ['name','value]
});
This will mean that every call to getParameters will always pass a parameter called calculationEntityId with the value 2

Now for the load example:


store.load(
{
params: {
entityId : 2
}
}
);
This means you're loading the store, providing a new parameter called entityId with value 2

mcadirci
22 Feb 2011, 5:25 AM
Thank you very much, this answer helped me alot.

Grolubao
22 Feb 2011, 5:33 AM
You're welcome, glad I could help you :)