diff --git a/static/plugin_dbui/src/grid/Panel.js b/static/plugin_dbui/src/grid/Panel.js index 92a29e7c8fde46c84a25487d80a77a2f41a50b50..9fd60b7a2211acbbf206804185d5e776da35d3d2 100644 --- a/static/plugin_dbui/src/grid/Panel.js +++ b/static/plugin_dbui/src/grid/Panel.js @@ -43,11 +43,18 @@ Ext.define('App.grid.Panel', { // At that step the plugins are not yet instantiate. // Thus wait the last moment. this.on('beforerender', this.onBeforeRender, this); + + // Reload he store when sort condition changed and + // when the remoteAction is true + this.on('sortchange', this.onSort, this); }, // Private method requires by the Ext JS component model beforeDestroy: function () { + this.un('beforerender', this.onBeforeRender, this); + this.un('sortchange', this.onSort, this); + // reset the store this.reset(); @@ -95,5 +102,24 @@ Ext.define('App.grid.Panel', { store.clearFilter(); store.filter(); } + }, + + /** + * Reload the store applying sort condition selected by the user. + * Do nothing when #remoteAction is false. + * + * @param {Ext.grid.header.Container} ct + * @param {Ext.grid.column.Column} column + * @param {String} direction + * @param {Object} eOpts + * + */ + onSort: function (ct, column, direction, eOpts) { + + "use strict"; + + if (this.remoteAction) { + this.getStore().loadPage(1); + } } });