From: <b_c...@us...> - 2012-11-09 00:09:36
|
Revision: 6471 http://jaffa.svn.sourceforge.net/jaffa/?rev=6471&view=rev Author: b_calderwood Date: 2012-11-09 00:09:28 +0000 (Fri, 09 Nov 2012) Log Message: ----------- After retrieving new records check if any of the new records are already in the existing set. If a duplicate is found this means our records are out of sync and we need to retrieve the full set again. Modified Paths: -------------- trunk/JaffaRIA/source/html/js/extjs/ux/grid/MultiGroupingStore.js Modified: trunk/JaffaRIA/source/html/js/extjs/ux/grid/MultiGroupingStore.js =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/ux/grid/MultiGroupingStore.js 2012-11-07 17:42:22 UTC (rev 6470) +++ trunk/JaffaRIA/source/html/js/extjs/ux/grid/MultiGroupingStore.js 2012-11-09 00:09:28 UTC (rev 6471) @@ -473,20 +473,39 @@ } if (Ext.isArray(o.errors) && o.errors.length>0) { var msg = ''; - for (var i=0; i<o.errors.length; i++) { - msg += (o.errors[i].localizedMessage || this.defaultLocalizedErrorMessage) + '\n<br>'; + for (var i=0; i<o.errors.length; i++) {msg += (o.errors[i].localizedMessage || this.defaultLocalizedErrorMessage) + '\n<br>';} + if (msg) {Ext.MessageBox.show( {title : 'Load Errors',msg : msg,buttons : Ext.MessageBox.OK,icon: Ext.MessageBox.ERROR});} + this.fireEvent('load', this); + } else { + //Check if any of the new records have keys that exist in the current store + var newRecs = o.records?o.records:[]; + var foundKey = false; + if (options && options.add){ + for (var i = 0; i < newRecs.length && !foundKey; i++){ + if (this.data && this.data.containsKey && newRecs[i] && newRecs[i].id && this.data.containsKey(newRecs[i].id)){ + foundKey = true; + } + } } - if (msg) { - Ext.MessageBox.show( { - title : 'Load Errors',//FIXME - msg : msg, - buttons : Ext.MessageBox.OK, - icon: Ext.MessageBox.ERROR - }); + //If a duplicate key is found then records are out of sync, reload all the required records. + if (foundKey){ + console.debug("Store.loadRecords : Need to refresh all records as they are out of sync"); + var pn = this.paramNames; + var oldLimit = (isNaN(options.params[pn.limit]) ? 0 : options.params[pn.limit]); + var oldStart = (isNaN(options.params[pn.start]) ? 0 : options.params[pn.start]); + options.params[pn.limit] = oldLimit < 0?oldLimit:(oldLimit + oldStart); + options.params[pn.start] = 0; + options.add = false; + options.initial = false; + delete this.nextKey; + this.fireEvent("loadexception", this); + console.debug("Store.loadRecords : Reload Using ",options); + this.load(options); + return; + }else{ + Ext.ux.grid.MultiGroupingStore.superclass.loadRecords.call(this, o, options, success); } - this.fireEvent('load', this); - } else { - Ext.ux.grid.MultiGroupingStore.superclass.loadRecords.call(this, o, options, success); + } } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |