From 4ebba55f9c0f7b7d8cdf42c78972e25ac8bf0bdb Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sat, 26 Mar 2011 20:07:50 +0000 Subject: [PATCH] Add an handler to update the total number of records after a write action. Have this information up to date is required by the paging plugin. --- static/plugin_dbui/src/appjsonstore.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/static/plugin_dbui/src/appjsonstore.js b/static/plugin_dbui/src/appjsonstore.js index 74450bfa..7f3d8bf8 100644 --- a/static/plugin_dbui/src/appjsonstore.js +++ b/static/plugin_dbui/src/appjsonstore.js @@ -77,6 +77,27 @@ App.data.DirectStore = Ext.extend(Ext.data.DirectStore, { // instantiate the store App.data.DirectStore.superclass.constructor.call(this, cfg); + + // update the total number of records + this.on('write', this.onWrite); + }, + + /** + * Handler to update the total number of records after a write action + * @param {Object} store + * @param {Object} action + */ + onWrite: function (store, action) { + + switch (action) { + case 'create': + store.totalLength += 1; + break; + + case 'destroy': + store.totalLength -= 1; + break; + } } }); -- GitLab