PDA

View Full Version : store.sync(), update api not called



Elfayer
17 Oct 2012, 6:24 AM
Hi,
I'm doing a sync() of a store:

this.getFilesStore().sync();
I have no call on my FireBug for the sync(), and the weird thing is that I'm doing a load() just after the sync(), and the load() is called.

Here is my Model:

Ext.define('EXC.model.File', {
extend: 'Ext.data.Model',
fields: [
{ name: 'fil_id', type: 'int' },
{ name: 'fil_label', type: 'string' },
{ name: 'fil_icon', type: 'string' },
{ name: 'fil_parent_id', type: 'int' },
{ name: 'fil_is_folder', type: 'bool' },
{ name: 'fil_description', type: 'string' },
{ name: 'fil_name', type: 'string' },
{ name: 'pth_id', type: 'int' },
{ name: 'ftp_id', type: 'int' },
{ name: 'fil_created', type: 'date', dateFormat: 'Y-m-dTH:i:s' },
{ name: 'fil_updated', type: 'date', dateFormat: 'Y-m-dTH:i:s' },
{ name: 'fil_expired', type: 'date', dateFormat: 'Y-m-dTH:i:s' },
{ name: 'fil_removed', type: 'bool' },
{ name: 'fil_deleted', type: 'bool' },
{ name: 'usr_id', type: 'int' },
{ name: 'usr_login', type: 'string' },
{ name: 'fil_editor', type: 'bool' }
],
proxy: new Ext.data.proxy.Ajax({
reader: new Ext.data.reader.Json({
totalProperty: 'total',
successProperty: 'success',
messageProperty: 'message',
root: 'data'
}),
writer: {
type: 'json',
encode: false,
allowSingle: false,
writeAllFields: true,
root: 'data'
},

actionMethods: {
read: 'POST',
update: 'POST'
},
api: {
read: '/File/GetFiles',
update: '/File/UpdateFiles'
}
})
});

Thanks in advance !

Farish
17 Oct 2012, 6:53 AM
there have to be dirty or removed records in the store in order for sync to send a request. before calling sync, you can call store.getNewRecords(), store.getRemovedRecords(), store.getUpdatedRecords(). print these to the console and see if there are actually any records to be updated. if all three are empty, then there is nothing to sync.

one other reason could be not using the idProperty to tell the store which field is the id field. by default its 'id' but you are using fil_id i think. see the following documention:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model-cfg-idProperty

Elfayer
17 Oct 2012, 11:16 PM
Yes, there is something like this. I fixed the problem. I was doing
item.data.fil_name = new_name; instead of
item.set('fil_name', new_name);