PDA

View Full Version : Writer not updating dirty records in grid using store.save()



scottmartin
6 Sep 2010, 6:44 AM
I have been trying to my app running using ScriptTagProxy,JsonWriter,JsonStore.

{success: true} is echo'd in the php
json is populated in XHR using ajax approach, not in store.save()

I have ... reviewed the writer example, reviewed many examples, researched the forum until my eyes bleed.
I have seen other reports of this, but I was not sure if it was resolved, as there was no mention of the solution.

I have step through my code using firebug. The save function seems to populate rs, etc in walk through of store.save ...but 'post' and 'response' are not sent.

If I use Ext.Ajax.request(), it seems to work fine. Hopefully this is a simple setting that I am overlooking.

Here is some of my code. Please let me know if I need to provide more info: (yes I used XDS for now)

Side note: Are they any working _simple_ examples using using this approach? (api,writer,php,sql). The writer example is impressive, but a bit overwhelming when you first getting started.

Regards,
Scott.



var proxy = new Ext.data.ScriptTagProxy({
api: {
read : 'data_query.php',
create : 'data_create.php',
update: 'data_update.php',
destroy: 'data_delete.php'
}
});





store_users = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
store_users.superclass.constructor.call(this, Ext.apply({
proxy: proxy,
storeId: 'store_users',
root: 'users',
// url: '../data/bms_users.json',
autoLoad: true,
autoSave: false,
successProperty : 'success',
totalProperty : 'totalCount',
idProperty: 'id_user',
reader: reader,
writer: writer,
listeners: {
exception: function() {
console.info(arguments);
}
},
fields: [.. ]
},cfg));
}
});
new store_users();


tbar:


xtype: 'button',
text: 'Save',
handler: onSave <- ajax approach works
/*
handler: function(){
var mystore = Ext.StoreMgr.get('store_users');
// mystore.commitChanges(); <- changes dirty status
mystore.save(); <-dirty status does not change
}
*/
},

Condor
6 Sep 2010, 6:48 AM
Your server needs to return the new/updated record data after a create or update.

scottmartin
6 Sep 2010, 8:45 AM
Where was the problem. I needed to add the callback.
http://www.sencha.com/forum/showthread.php?22990

Regards,
Scott.