From fbe1ce9fc7905789167abb758e950a7f6bc24e79 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sat, 26 Mar 2011 16:03:26 +0000 Subject: [PATCH] Polish. the new handler onInit is only execute once. --- static/plugin_dbui/src/appgridpaging.js | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/static/plugin_dbui/src/appgridpaging.js b/static/plugin_dbui/src/appgridpaging.js index a71ae992..ea52d957 100644 --- a/static/plugin_dbui/src/appgridpaging.js +++ b/static/plugin_dbui/src/appgridpaging.js @@ -3,8 +3,8 @@ * The ptype of this component is pGridPaging. * * - * NOTE: the number of row load in hte grid the first time is defined - * by the grid when loading the store. + * NOTE: the number of row load in the grid at the first time + * is defined by the grid when loading the store. * * @version $Id$ * @@ -25,9 +25,7 @@ App.grid.Paging = Ext.extend(Object, { var bbar; - grid.pagingInitialized = false; - - // associate the bbar to the grid store + // link the bbar and the grid store bbar = grid.getBottomToolbar(); bbar.bindStore(grid.store); @@ -54,13 +52,17 @@ App.grid.Paging = Ext.extend(Object, { bbar.show(); - // if the store is already load initialize the parameters - // of the paging and slider widgets - // Otherwise, way the store is loaded + // Initialize the parameters of the paging and slider widgets. + // Depends on the status of the store. + // Initialization is only performed once. if (grid.store.getTotalCount() > 0) { - this.onStoreLoad.call(grid, grid.store); + + this.onInit.call(grid, grid.store); + } else { - grid.store.on('load', this.onStoreLoad, grid); + + grid.store.on('load', this.onInit, grid, {single: true}); + } }, @@ -81,10 +83,11 @@ App.grid.Paging = Ext.extend(Object, { }, /** - * Handler to tune the number of rows per page and the number of page + * Handler to initialize the number of rows per page and the number of page */ - onStoreLoad: function (store, records, options) { + onInit: function (store, records, options) { + console.log('fgfghgh'); var bbar, grid = this, nRows = store.getCount(), @@ -94,8 +97,6 @@ App.grid.Paging = Ext.extend(Object, { return; } - grid.pagingInitialized = true; - bbar = grid.getBottomToolbar(); bbar.pageSize = nRows; -- GitLab