View Full Version : How to get the store to send his parameters in JSON ?

13 Apr 2012, 6:04 AM

I want a store to be able to send POST requests with parameters encoded in JSON when loading. Here is the code I use for now :

var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
url : 'SingleValueSerieReader',
reader: {
type: 'json',
root: 'users'
writer: {
type: 'json'
extraParams: {
codeKpi: 'KPI001',
periode: '20120401',
categorie1: 'TEST',
categorie2: 'TEST'
actionMethods: {
create: "POST",
read: "POST",
update: "POST",
destroy: "POST"
autoLoad: true

I don't know if I have misunderstood the meaning of the JSON writer, because it seemed to be what I was searching for. But my requests still have this content :


When I'm looking for something like this :

{codeKpi : "KPI001", periode: "20120401", categorie1: "TEST", categorie2: "TEST"}

Thanks for your help !

13 Apr 2012, 11:00 AM
You are sending as parameters so, it will send accordingly.

form.submit(); // sends as form data
rec.save(); form.updateRecord() // sends as json

If you want to send parameters as json, then you can do something like:

mydata = [];
mydata.push({ codeKpi: 'KPI001' });

actionMethods: 'POST', // instead setting each

params : { // or extraPamas
data: Ext.encode(mydata)


17 Apr 2012, 1:21 AM
Thanks for the answer, that's exactly what I needed.