View Full Version : Reloading store after save does no pick up last record inserted

23 Jan 2011, 8:08 AM
I have a grid with RowEditor plugin. When I click save on a new record, the data is inserted into the database properly and the (below) store.reload refreshes the data on a new Ajax call. The problem is that when the store does a reload the last record inserted does not get returned in the new JSON response from the database EXCEPT (and the weird part) if this is the FIRST record I input for the session.

Any thoughts here on the database interaction?

When I click the save button on the roweditor, it calls this function

// afteredit listener on roweditor
,afteredit: {
scope: this
,fn: this.onUpdateRecord


,onUpdateRecord : function(roweditor,update,record,idx) {
var detailGrid = this.getComponent('millCostGrid');
var store = detailGrid.getStore();

23 Jan 2011, 8:17 AM

First record exception stated above is inaccurate. Sometimes it shows up, sometimes it doesn't.

I am guessing there needs to be a delay between the writing of the record and the requery of the database. Is there a pause that can be inserted between the store.save() and the store.reload() ?

23 Jan 2011, 6:13 PM
Thanks to a private message - introducing a delay worked

var myAutoReload = new Ext.util.DelayedTask(function(){
myAutoReload.delay(2000); // 2 seconds delay

Haven't tried a minimal delay yet