PDA

View Full Version : [OPEN] [OPEN]Store autoSave: true does not work



oe.elvik
10 Mar 2011, 2:31 AM
form.getForm().updateRecord(record);
or any other operation like removing record from store does not send request to server.

Here is my model and store:

Ext.regModel('person', {
fields: [....],

proxy: {
type: 'rest',
url : 'resources/persons',
reader: {
type: 'json',
root: 'persons'
}
},


Ext.regStore('persons', {
model: 'person',
autoLoad: true,
autoSave: true
});

oe.elvik
10 Mar 2011, 2:47 AM
temporery fix:


Ext.getStore('persons').on('datachanged', function(){Ext.getStore('persons').sync()});

oe.elvik
11 Mar 2011, 1:07 AM
No, that did'nt solve it..

The fix cased the store to send an invalid PUT request right after my POST request when creating new records.

Help anyone?

Greg.Veres
13 Mar 2011, 1:41 PM
We are running into the same problem. It seems like a very serious design flaw for the store or we are just using the store incorrectly.

I haven't tried this yet, I just thought of it earlier today, but I am thinking that we could do something like this:

put a listener on save and then turn off autosave.
put a listener on write

During the write method you would want to see if there are any other changes to the store waiting to be saved. You can do this by calling save(). It returns the number of changes. If this returns -1, then you can turn on autosave.
If this is greater than 0, you use that as a counter for write. You wait for that many write events and do the same thing of calling save again to see if any more changes have been accumulated. If not, turn on autosave. If there are, do it again.

Like I said, I haven't tried this yet. But I think it will work. We have worked around this bug in other areas of our app, with listeners on write. But in that case we did the horrible thing of greying out the entire UI because if we didn't do that it leads to horrible consequences on our backend by having extra records POSTed.

Greg