PDA

View Full Version : [SOLVED] some records of a grid store are not synchronized when I type store.sync()



flamant
21 Jan 2012, 3:20 PM
Hi,
I delete, update, create records in a grid store. Before synchronizing them (store.sync()) I checked that the records are marked as deleted/updated/created/ (store.getRemovedRecords()/store.getUpdatedRecords()/store.getNewRecords()). But only some request are sent to the server (it seems that only create request are sent)

here is my store



translatedTextJsonStore[translatedEntityName] = new Ext.data.Store({
model: 'Writer.TranslatedText',
autoLoad: false,
autoSync: false,
proxy: {
type: 'ajax',
api:{
read: "./get" + translatedEntityName + "TranslatedTextList.htm?id=" + translatedEntityId,
create: "./create" + translatedEntityName + "TranslatedText.htm?id=" + translatedEntityId,
update: "./update" + translatedEntityName + "TranslatedText.htm?id=" + translatedEntityId,
destroy: "./delete" + translatedEntityName + "TranslatedText.htm?id=" + translatedEntityId
},
reader: {
type: 'json',
root: 'records',
idProperty: 'id',
successProperty: 'success'
},
writer: {
type: 'json',
writeAllFields: true,
root: 'records',
encode: true,
allowSingle: false
}

},
listeners: {
load: function(store, records, successful, operation, opts) {
commitStoreChanges(store);
}
}
});


here is how I sync the store (I have an array "stores" of store)



while (stores.length > 0) {
stores[0].getProxy().extraParams = { resultingId: resultingId };
console.log('removed');
for (var i = 0; i < stores[0].getRemovedRecords().length; i++) {
console.log(stores[0].getRemovedRecords()[i]);
}
console.log('updated');
for (var i = 0; i < stores[0].getUpdatedRecords().length; i++){
console.log(stores[0].getUpdatedRecords()[i]);
}
console.log('new');
for (var i = 0; i < stores[0].getNewRecords().length; i++) {
console.log(stores[0].getNewRecords()[i]);
}
stores[0].sync();
stores.shift();
}


Thank you in advance for your answers

flamant
22 Jan 2012, 1:05 AM
Hi,
I found the solution.

In fact the first request (create) return success = false and so the following request are not sent