From 9651e43ef2eb797b933f87fd0da467acd5993225 Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <legac@cppm.in2p3.fr>
Date: Mon, 10 Dec 2012 17:07:22 +0100
Subject: [PATCH] Remove the reset button. The paging plugin is reset when
 receiving the resetgrid event.

---
 static/plugin_dbui/src/pgridpaging.js | 42 +++++++++++----------------
 1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/static/plugin_dbui/src/pgridpaging.js b/static/plugin_dbui/src/pgridpaging.js
index d4286a24..34fb7329 100644
--- a/static/plugin_dbui/src/pgridpaging.js
+++ b/static/plugin_dbui/src/pgridpaging.js
@@ -19,13 +19,12 @@ App.grid.Paging = Ext.extend(Object, {
     ptype: 'pGridPaging',
 
     /**
-     * Private attributs for internationalization
+     * Private attribute for internationalisation
      */
-    textReset: 'Reset',
     textSlider: 'Rows per page',
     
     /**
-     * Plugin initialization
+     * Plugin initialisation
      */
     init: function (grid) {
 
@@ -37,7 +36,7 @@ App.grid.Paging = Ext.extend(Object, {
         // replace the bottomtool bar by the pagingtool bar
         grid.bottomToolbar = bbar;
 
-        // add slider and export button
+        // add slider
         bbar.add(               
             '-',
             this.textSlider, 
@@ -50,18 +49,12 @@ App.grid.Paging = Ext.extend(Object, {
                 },
                 minValue: 1,
                 width: 100
-            }, '-', {
-                xtype: 'button',
-                iconCls: 'xaction-download',
-                listeners: {click: this.onReset,
-                         scope: grid},
-                tooltip: this.textReset
             }, '-'
          );       
         
-        // Initialize the parameters of the paging and slider widgets.
+        // Initialise the parameters of the paging and slider widgets.
         // Depends on the status of the store.
-        // Initialization is only performed once.
+        // Initialisation is only performed once.
         if (grid.store.getTotalCount() > 0) {
             
             this.onInit.call(grid, grid.store);
@@ -75,6 +68,10 @@ App.grid.Paging = Ext.extend(Object, {
         // update the slider parameter after a write action
         // which destroy and create records
         grid.store.on('write', this.onWrite, grid);
+        
+        // reset paging and slide parameter on a grid reset
+        grid.on('resetgrid', this.onReset, grid);
+        
     },
     
     /**
@@ -88,7 +85,7 @@ App.grid.Paging = Ext.extend(Object, {
     },
     
     /**
-     * Handler to initialize the number of rows per page and the number of page
+     * Handler to initialise the number of rows per page and the number of page
      * the scope is the grid
      */
     onInit: function (store, records, options) {
@@ -109,26 +106,21 @@ App.grid.Paging = Ext.extend(Object, {
     },
     
     /**
-     * Handler to reload the grid store
+     * Handler to reset the paging parameters
      * The scope is the grid 
      */
     onReset: function() {
         var bbar,
-            grid = this,
-            nRows = 10;
+            grid = this;
 
         bbar = grid.getBottomToolbar();
-        bbar.pageSize = nRows;
-        
-        slider = bbar.findByType('slider')[0];
+        bbar.pageSize = grid.nRows;
+        bbar.moveFirst();
         
-        grid.store.load({params: {start: 0, limit: nRows}, callback: function() {
-            bbar.moveFirst();
-            slider.setMaxValue(grid.store.getTotalCount());
-            slider.setValue(nRows);    
-        }, scope: this});
+        slider = bbar.findByType('slider')[0];        
+        slider.setMaxValue(grid.store.getTotalCount());
+        slider.setValue(grid.nRows);
 
-        
     },
     /**
      * Handler to update the slider/bottomToolBar parameters after a store write action.
-- 
GitLab