View Full Version : EXTJS 4: What to return from server when UPDATE (store.sync) is called

16 Dec 2011, 3:28 AM

I have overwritten the json.reader and writer to do some data manipulation before data ist stored or read from or to the server.

Now I have a problem when calling my UPDATE service during store.sync(). When I obly return {success:true} from the server I cannot re-manipulate the data in the reader and the record in the store is changed to manipulated data.

When I return the record from the server as posted: {success:true, data:[{....}]} the records are re-manipulated perfectly but they are also doubled in the store. This is not an issue of my (re)manipulation because this record doubling happens also without the manipulation. Especially the idProperty (id) is unchanged, though I have to records with the same id in my store.

Now, how can I return a record in the UPDATE service without having doubled it afterwards in the store?

Thanks for your help,

16 Dec 2011, 3:50 AM
first, make sure that you call record.commit() after your own changes to remove the dirty flag. i never had issues with duplicated records so far, and especially if the idProperty is set correctly it should not happen that the store gets more than one entry with the same id.

so, check your overrides as well and provide some coding sniplets for additional help.

19 Dec 2011, 12:55 AM
I finally found the reason for the described misbehavior: Within my model I had overwritten the constructor like this:

constructor: function(config) {

I do not really remember why I did this, but since I deleted the constructor, everything works fine. But due to the fact that I am relatively new to EXT and JS I do not understand why this happens. Can anyone explain it to me? Thanks in advance!

19 Dec 2011, 1:42 AM
remove the [ ] in the parent call and it should work. the constructor can get used for dynamically changing configs, often used for stores etc. every child class of component has an initComponent method which i would prefer to use.