From f179fe041897ce04f57ccad659164c8c90d93337 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <legac@cppm.in2p3.fr> Date: Mon, 10 Dec 2012 17:02:40 +0100 Subject: [PATCH] Introduce the Store.restoreWhere method. --- static/plugin_dbui/src/grid.js | 20 +++++--------------- static/plugin_dbui/src/jsonstore.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/static/plugin_dbui/src/grid.js b/static/plugin_dbui/src/grid.js index 2cecddb2..59250ef6 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 0a70891f..cf18283b 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; + } + } } }); -- GitLab