PDA

View Full Version : How to sync store without adding a record to store



rakesh.h
25 Jun 2014, 3:28 AM
Hi,

I have a store with records. All CRUD operations are done through service calls. If suppose there is a table with columns Id and Name. There is a unique key constraint for 'Name' column. I will try to create a record which already exist in the database.

store.add(record);
store.sync( {
success: function()
{
Ext.Msg.alert('Status', 'Successfully saved');
},
failure: function()
{
Ext.Msg.alert('Attention', 'Failed to save');
},
callback: function()
{
store.load();
},
scope: this
})
As the new record is a duplicate record, database will throw exception, i ll get below message and store will be loaded.

Ext.Msg.alert('Attention', 'Failed to save');

If suppose the service call & response is slow, store.add(record) will add record to store and i can see the duplicate record in grid. Due to slow response from service, store.sync() will not repond immediately. Database throws exception exception saying duplicate entry and 'Failed to save' message will be shown and store ll be reloded.

My question is how can I avoid record being added to grid till i get response from store.sync().

Please help me.

Thanks & regards
Rakesh

Gary Schlosberg
5 Jul 2014, 9:43 AM
How slow is the response time from the server on average?