diff --git a/models/db_widgets.py b/models/db_widgets.py index 595fdc0a09c3eabe5b61f17aa60c8b1f56269c07..aa6ba2bd3be478787ee8f73066c65cf3fb6aa967 100644 --- a/models/db_widgets.py +++ b/models/db_widgets.py @@ -77,8 +77,8 @@ pgm.customize_form('publications', ) -pgm.customize_grid(plugins=['pGridRowEditorToolbar', - 'pGridRowEditorContextMenu']) +pgm.customize_grid(plugins=['pGridRowEditorContextMenu', + 'pGridPagingBar',]) # add template column to grid diff --git a/modules/plugin_dbui/dbsvc.py b/modules/plugin_dbui/dbsvc.py index c7233585301ad67946aee1d54e6f91b989beae35..aa683f06e04ad7cd10494b1375bd4d15f2d6e4a0 100644 --- a/modules/plugin_dbui/dbsvc.py +++ b/modules/plugin_dbui/dbsvc.py @@ -380,17 +380,18 @@ class DbSvc(BaseSvc): query = '' if "where" in self._vars: query = self._encode_query(self._list(self._vars["where"])) - + # handle paging options (see Ext.PagingToolbar) - kwargs = {} + # Count the number of record in the table --require for the paging + kwargs, results = {}, None if 'start' in self._vars and 'limit' in self._vars: kwargs['limitby'] = (int(self._vars.start), int(self._vars.limit)) - - # proceed the select + results = self._db(self._db[table].id).count() + rows = self._db(query).select(*fields, **kwargs) self._debug("End DbSvc.read") - return {"success": True, "data": rows_serializer(rows)} + return {"success": True, "results": results, "data": rows_serializer(rows)} def select(self): diff --git a/static/plugin_dbui/lib/appgrid.js b/static/plugin_dbui/lib/appgrid.js index 98f0e37d7661a888a78ccf57e4899292ef7dca1a..548efda1df72bc94b38e652221613fed980a131f 100644 --- a/static/plugin_dbui/lib/appgrid.js +++ b/static/plugin_dbui/lib/appgrid.js @@ -70,8 +70,10 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { // the columns model this.columns = this.model.colModel; - // empty top toolbar -- require by the toolbar plugin + // empty top toolbar/bottomnar -- required by the plugins this.tbar = []; + this.bbar = new Ext.PagingToolbar(); + this.bbar.hide(); // initialize the underlying class. DON'T MOVE App.grid.Grid.superclass.initComponent.call(this); diff --git a/static/plugin_dbui/lib/appgridpaging.js b/static/plugin_dbui/lib/appgridpaging.js new file mode 100644 index 0000000000000000000000000000000000000000..350143c3f376f7d2b8a9c995db2697d6496bc512 --- /dev/null +++ b/static/plugin_dbui/lib/appgridpaging.js @@ -0,0 +1,23 @@ +/** + * The paging bottom bar plugin + * + * The ptype of this component is pGridPagingBar. + * + * @version $Id$ + * + */ +Ext.namespace('App.grid'); + +App.grid.PagingBar = Ext.extend(Object, { + + init: function(grid){ + + var bbar = grid.getBottomToolbar(); + bbar.bindStore(grid.store); + bbar.pageSize = 2; + bbar.doRefresh(); + bbar.show(); + }, +}); + +Ext.preg('pGridPagingBar', App.grid.PagingBar); diff --git a/static/plugin_dbui/lib/appjsonstore.js b/static/plugin_dbui/lib/appjsonstore.js index 95e7dde1529c15371b132c5ae1064417697aba0c..adc05259b3bc817cf7d4b1968577f0279563109d 100644 --- a/static/plugin_dbui/lib/appjsonstore.js +++ b/static/plugin_dbui/lib/appjsonstore.js @@ -152,6 +152,7 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { this.reader = new Ext.data.JsonReader({ root: 'data', fields: this.model.fields, + totalProperty: 'results', idProperty: this.model.idProperty, }); }