PDA

View Full Version : Phantom record is created when updating the store



umenokin
3 Oct 2011, 4:27 AM
When I try to update a record in the store it creates a phantom record.
Downloading from server works fine.

Store:
Ext.define('Admin.store.Projects', {
extend: 'Ext.data.Store',
model: 'Admin.model.Project',


autoSync: true,


proxy: {
type: 'ajax',
api: {
read: '/admin/request/projects/view',
create: '/admin/request/projects/create',
update: '/admin/request/projects/update',
destroy:'/admin/request/projects/destroy'
},
reader: {
type: 'json',
successProperty: 'success',
messageProperty: 'message'
//method: 'GET' or POST
},
/*writer: {
type: 'json',
writeAllFields: false,
method: 'GET' or POST
},*/
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});

Model:
Ext.define('Admin.model.Project', {
extend: 'Ext.data.Model',


fields: ['id', 'title', 'type_id', 'location', 'excerpt', 'description', 'completion_date', 'order_index']
});

And then somewhere in code:
...

var mainStore = this.getStore('Projects');
mainStore.getAt(j).set('order_index', i);

...

mainStore.sync();