PDA

View Full Version : Calendar + httpProxy + CRUD problem



hbeing123
3 Jan 2011, 10:52 AM
hi guys, I'm having a serious problem getting the calendar component to work properly with a httpproxy.... I can't get it to fire the update or destroy api actions... someone mentioned this happened when you have an invalid idProperty, I really don't think this is the case... basically whenever I save an event, move an event or delete an event is only ever sends the create action.. .another problem I've had is that the action is transmitted twice and even the read command at the beginning runs 5 times, I can't understand why... but the read command is fine I think.. here is the JSON read response:




{"message":"Data Read","success":true,"evts":[{"ad":0,"start":"2011-01-03 15:30:27.0","rem":"","end":"2011-01-03 17:30:27.0","id":1001,"url":"","notes":"Haircut","title":"Haircut","cid":1},{"ad":0,"start":"2011-01-03 09:34:55.0","rem":"","end":"2011-01-03 11:35:16.0","id":1002,"url":"","notes":"","title":"test","cid":1},{"ad":"","start":"2011-01-02 15:35:53.0","rem":"","end":"2011-01-03 18:35:58.0","id":1003,"url":"","notes":"","title":"Clear","cid":2}]}


and the code:





var writer = new Ext.data.JsonWriter({
encode: false // <--- false causes data to be printed to jsonData config-property of Ext.Ajax#reqeust
});

var proxy = new Ext.data.HttpProxy({
api: {
read : '../cfm/model/getEvents.cfm?action=read',
create : '../cfm/model/getEvents.cfm?action=create',
update : '../cfm/model/getEvents.cfm?action=update',
destroy : '../cfm/model/getEvents.cfm?action=destroy'
}
});

this.eventStore = new Ext.data.JsonStore({
id: 'eventStore',
root: 'evts',
idProperty: 'id',
writer: writer,
proxy: proxy,
fields: Ext.calendar.EventRecord.prototype.fields.getRange(),
sortInfo: {
field: 'StartDate',
direction: 'ASC'
},
listeners: {

exception : function(proxy, type, action, options, res, arg) {
//console.warn(arguments);
if (type === 'remote') {

Ext.Msg.show({
title: 'REMOTE EXCEPTION',
msg: res.raw.message + ' ' + action,
icon: Ext.MessageBox.ERROR
});
if (action != 'read') {
this.reload();
}
}
}
}

});


Please help as this is really messing up my project timelines...even a workaround would be helpful, I've got to be able to do updates and removes whenever the store changes.

hbeing123
3 Jan 2011, 11:01 AM
Sorry already fixed this... it was using id:'eventStore' for a JsonStore... should've been storeId:'eventStore'.

hbeing123
3 Jan 2011, 11:03 AM
still wondering about this firebug going crazy though... every read, update, create seems to fire twice every time and the read at the beginning fires no less than 5 times...

hbeing123
3 Jan 2011, 11:08 AM
haha, forget it, I understand it now... it's reading one record at a time...