golly
8 Dec 2011, 8:24 AM
Hi guys. I vahe a problem with the JSON Writer. I'm using an ASP.NET server. I want to create a record and put it in a store. This part is working very well. But the create method of the api is putting the record in parameters. Is there any way to have it in one single json param? Here is my code:
this.server = "http://localhost:3361/Backend/Proxy.aspx";
Ext.define('example', {
extend: 'Ext.data.Model',
fields: [{name : "ID"},
{name: "description"},
{name: "datetime"},
{name: "activ"},
{name: "employee"},
{name: "place"}]
});
this.baum = new Ext.data.Store({
id:'baum',
model:'example',
autoSync:true,
proxy(
{
headers:{"Content-type":"application/json"},
type:'jsonp',
api:{
create:this.server+'/Appointment/Create',
read:this.server+'/Appointment/Read',
update:this.server+'/Appointment/Update',
destroy:this.server+'/Appointment/Destroy'
},
reader: {
type: 'json',
idProperty:"ID",
totalProperty:"d.results",
successProperty:"d.success",
messageProperty:"d.message",
root:"data"
},
writer: {
type: "json",
writeAllFields: false,
root: "data"
},
},
sortInfo:{field:"datetime",direction:"ASC"},
});
var store = Ext.StoreMgr.lookup('baum');
//Using this in insert****************************
var record = new example({
ID:"77",
description: "someTitle",
datetime: "12-12-1212",
employee: "someEmployee",
place: "home"
});
//Or this... its the same thing***********************
store.insert(0,{
ID:"77",
description: "someTitle",
datetime: "12-12-1212",
employee: "someEmployee",
place: "home"
});
The Network activity simply show the create:
- http://localhost:3361/Backend/Proxy.aspx/Appointment/Create?_dc=1323360958401&records=ID=77&description=someTitle&datetime=12-12-1212&employee=someEmployee&place=home&activ=&callback=Ext.data.JsonP.callback2
But i need it like the root in the writer (In one JSON Param):
- http://localhost:3361/Backend/Proxy.aspx/Appointment/Create?_dc=1323360958401&data=HTML ENCODED JSON STRING&callback=Ext.data.JsonP.callback2
In ExtJS 3.4 a good friend of mine used the ScripttagProxy and the JSON Param generated automatically.
Can anyone help me with this problem?
PS.: The JSON Writer example didn't help
this.server = "http://localhost:3361/Backend/Proxy.aspx";
Ext.define('example', {
extend: 'Ext.data.Model',
fields: [{name : "ID"},
{name: "description"},
{name: "datetime"},
{name: "activ"},
{name: "employee"},
{name: "place"}]
});
this.baum = new Ext.data.Store({
id:'baum',
model:'example',
autoSync:true,
proxy(
{
headers:{"Content-type":"application/json"},
type:'jsonp',
api:{
create:this.server+'/Appointment/Create',
read:this.server+'/Appointment/Read',
update:this.server+'/Appointment/Update',
destroy:this.server+'/Appointment/Destroy'
},
reader: {
type: 'json',
idProperty:"ID",
totalProperty:"d.results",
successProperty:"d.success",
messageProperty:"d.message",
root:"data"
},
writer: {
type: "json",
writeAllFields: false,
root: "data"
},
},
sortInfo:{field:"datetime",direction:"ASC"},
});
var store = Ext.StoreMgr.lookup('baum');
//Using this in insert****************************
var record = new example({
ID:"77",
description: "someTitle",
datetime: "12-12-1212",
employee: "someEmployee",
place: "home"
});
//Or this... its the same thing***********************
store.insert(0,{
ID:"77",
description: "someTitle",
datetime: "12-12-1212",
employee: "someEmployee",
place: "home"
});
The Network activity simply show the create:
- http://localhost:3361/Backend/Proxy.aspx/Appointment/Create?_dc=1323360958401&records=ID=77&description=someTitle&datetime=12-12-1212&employee=someEmployee&place=home&activ=&callback=Ext.data.JsonP.callback2
But i need it like the root in the writer (In one JSON Param):
- http://localhost:3361/Backend/Proxy.aspx/Appointment/Create?_dc=1323360958401&data=HTML ENCODED JSON STRING&callback=Ext.data.JsonP.callback2
In ExtJS 3.4 a good friend of mine used the ScripttagProxy and the JSON Param generated automatically.
Can anyone help me with this problem?
PS.: The JSON Writer example didn't help