PDA

View Full Version : Multiple forms sync with store



abegey
7 Jan 2013, 7:12 AM
Hi all,

i'm trying to synchronize a store with a container with forms (instead of a grid or any 'usual' container)

I've succeded to synchronize the store with every new form and every closed form

for information, here is how I add form linked to a new record and how I delete record from store


var record = Ext.create('project.model.myModel');
this.getMyStoreStore().add(record);
form.getForm().loadRecord(record);


this.getmyStoreStore().remove(form.getForm().getRecord());


I thought it would be easy to update and sync store at each update of field
onRender of my container, I create on the fly every form and link them to each record of the store


this.getMyStoreStore().each(function(record){
var form = this.addForm();
form.getForm().loadRecord(record);
}, this);


Here is my code to do that in a method used at every field update


var record = form.getForm().getRecord();
var values = form.getForm().getValues();
record.set(values);
this.getMyStoreStore().sync();


And I don't know why, it doesn't work. In some way only one field in my form is saved...
can anyone explain this ? what's my mistake
Thanks in advance

scottmartin
7 Jan 2013, 3:21 PM
What do you see on the NET tab when you are syncing your data? Is all the information sent to the server?

I am not sure I understand your statement about update/sync at each field update? You should update your entire form once after it has been updated.

Have a look in FB/Chrome dev tools and see what is going on behind the scenes. I would bet it is not acting as you suspect.

Scott.

abegey
7 Jan 2013, 7:40 PM
Thanks for your answer.
In fact I use a localstorage to make a proof of concept before create a server side... so it won't be send to any server I think (and I don't see any data in the NET tab)
I use Chrome tools to log out store's state each time I update data and store seem to be ok, but when I do a sync, if I refresh the page, the localstorage hasn't the good status of data.

I want to be able to sync for each field change so the user won't have to do it manually... each change will save the record into the localstorage.