diff --git a/static/plugin_dbui/src/grid.js b/static/plugin_dbui/src/grid.js index 2cecddb2a3fa66d4f57caba550d30174029a89c4..59250ef664ca4cf59f3f7a23088e7ee1abf25e4e 100644 --- a/static/plugin_dbui/src/grid.js +++ b/static/plugin_dbui/src/grid.js @@ -88,31 +88,21 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { var action, i; - // private function to emitt the resetgrid event + // private function to emit the resetgrid event function fireReset() { this.fireEvent('resetgrid'); } - // parameters for the store load action + // parameters defining the store load action action = {callback: fireReset, scope: this}; if (this.getBottomToolbar() instanceof Ext.PagingToolbar) { action.params = {start: 0, limit: this.nRows}; } // restore initial where condition of the store - // in order to remove filter condition - if ('where' in this.store.baseParams) { - - if (this.store.initialWhere) { - this.store.baseParams.where = []; - for (i = 0; i < this.store.initialWhere.length; i += 1) { - this.store.baseParams.where.push(this.store.initialWhere[i]); - } - } else { - delete this.store.baseParams.where; - } - } - + // in order to remove remote filter condition + this.store.restoreWhere(); + // reload the store and fire the resetgrid event this.store.load(action); } diff --git a/static/plugin_dbui/src/jsonstore.js b/static/plugin_dbui/src/jsonstore.js index 0a70891f0a6da01e6f55f913589221030d6f7070..cf18283b6aa6ef8260fa653c814bc73ea9fb1941 100644 --- a/static/plugin_dbui/src/jsonstore.js +++ b/static/plugin_dbui/src/jsonstore.js @@ -115,6 +115,28 @@ App.data.DirectStore = Ext.extend(Ext.data.DirectStore, { store.totalLength -= 1; break; } + }, + + /** + * Restore the where conditions to the original values. + * Useful to remove remote filter condition. + */ + restoreWhere: function () { + + var i; + + if ('where' in this.baseParams) { + + if (this.initialWhere) { + this.baseParams.where = []; + for (i = 0; i < this.initialWhere.length; i += 1) { + this.baseParams.where.push(this.initialWhere[i]); + } + + } else { + delete this.baseParams.where; + } + } } });