PDA

View Full Version : [SOLVED] Store's write event not firing after CRUD action... what am I doing wrong?



JKeane
3 Dec 2009, 8:44 AM
I have a Store which has been configured to write its various CRUD actions through different API calls. Everything saves fine (and returns 200 from the server) but the Store's write event never fires. Eventually I'd like successfully written records to be committed to clear the visual indicator that the record contains dirty rows, but that's not written yet, as you'll see below.

Any advice?


feeStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
api: {
create: "all_fees_write.cfm?action=create",
read: "all_fees_write.cfm?action=read",
update: "all_fees_write.cfm?action=update",
destroy: "all_fees_write.cfm?action=destroy"
}
}),
autoSave: false,
batch: false,
root: "data",
totalProperty: "recordcount",
idProperty: "projectproductfinancemonthseq",
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
}),
baseParams: {
(params go here)
},
fields: [{
name: "projectproductfinancemonthseq"
},
{
name: "financefeeseq"
},
{
name: "financefee"
},
{
name: "calendaryear"
},
{
name: "calendarmonth"
},
{
name: "projectproductseq"
}],
listeners: {
write: function (store, action, result) {
alert(Ext.util.JSON.decode(result))
}
}
});

JKeane
7 Dec 2009, 1:07 PM
It turns out the problem laid not in my code, but in how my response was formed.

I was returning a string whose value was either "true" or "false", depending on the success/failure of the operation. The correct way to handle this is to pass back a success object whose value is either true or false. (like, to use the json vernacular, {success: true})

Not passing the response in this format caused the event to be bypassed altogether.

I found my answer here, if it helps anyone else out.
http://www.extjs.com/forum/showthread.php?t=83556