PDA

View Full Version : JsonWriter + listful



varunach
4 Apr 2011, 10:04 AM
Hi,

This is my JsonStore config



var store = new Ext.data.JsonStore({
proxy : calProxy,
autoLoad : true,
autoDestroy : true,
autoSave : true,
restful : true,
successProperty : 'success',
root : 'data',
totalProperty : 'total',

idProperty : Ext.ensible.cal.CalendarMappings.CalendarId.mapping
|| 'id',
fields : Ext.ensible.cal.CalendarRecord.prototype.fields.getRange(),
baseParams : {
success : true
},
writer : new Ext.data.JsonWriter({
encode : false,
writeAllFields : true,
listful : true
});
});


I have set listful : true yet it is posting my a single object like this:

{"data":{"calendarId":"ext-gen205","title":"work","description":"work","isHidden":false,"colorId":"2"}}

But this is how it should be posting the data:

{"data":[{"calendarId":"ext-gen205","title":"work","description":"work","isHidden":false,"colorId":"2"}]}

how do i get it working correctly?

mankz
4 Apr 2011, 10:26 AM
Ext version?

varunach
4 Apr 2011, 11:26 AM
3.3.1

mankz
4 Apr 2011, 11:29 AM
Hmm, your store is not specifying any 'api', see docs for description.

varunach
4 Apr 2011, 11:32 AM
it has a proxy config.. and data is getting received from and sent to the server. Data from DB is getting loaded and is visible correctly. The data is also getting posted to the server cause i'm getting exceptions in the server side too because of the format of the data in which it is sent.

mankz
4 Apr 2011, 11:34 AM
Could you post entire store/proxy cfg?

varunach
4 Apr 2011, 11:35 AM
and oh.. by the way..

this link isn't working:

http://www.ext-scheduler.com/examples/ganttadvanced/gantt.html

:)

varunach
4 Apr 2011, 11:38 AM
Json store already posted.. haven't changed anything in it..

Proxy :



var calUrlRoot = 'rest/dashboardService/calendar/calendarList';
var calProxy = new Ext.data.HttpProxy({
api : {
read : {
url : calUrlRoot + '/48', //TODO Remove hardcode and replace with userId fetched from context.
method : 'GET'
},
update : {
url : calUrlRoot,
method : 'PUT'
},
destroy : {
url : calUrlRoot,
method : 'DELETE'
},
create : {
url : calUrlRoot,
method : 'POST'
}

}
});

mankz
4 Apr 2011, 10:23 PM
and oh.. by the way..

this link isn't working:

http://www.ext-scheduler.com/examples/ganttadvanced/gantt.html

:)

Thanks for the heads up, link is now fixed. The correct link is http://ext-scheduler.com/examples/advanced/advanced.html :)

mankz
4 Apr 2011, 10:28 PM
"restful" means it will not be using batching. Turn it off if you want to pass items in array/list form.

From Ext source:



if (this.writer.listful === true && this.restful !== true) {
rs = (Ext.isArray(rs)) ? rs : [rs];
}

varunach
5 Apr 2011, 4:33 AM
thanks.. that solved it.. :D..

they should put such things in the api..

varunach
5 Apr 2011, 4:35 AM
and the live demo link on you home page (http://www.ext-scheduler.com/gantt.html) still redirects to the dead link..