Skip to content
Snippets Groups Projects
Commit 27256d41 authored by Renaud Le Gac's avatar Renaud Le Gac
Browse files

Introduce the grid plugin pGridPaging.

parent 2a7baa80
No related branches found
No related tags found
No related merge requests found
...@@ -77,8 +77,8 @@ pgm.customize_form('publications', ...@@ -77,8 +77,8 @@ pgm.customize_form('publications',
) )
pgm.customize_grid(plugins=['pGridRowEditorToolbar', pgm.customize_grid(plugins=['pGridRowEditorContextMenu',
'pGridRowEditorContextMenu']) 'pGridPagingBar',])
# add template column to grid # add template column to grid
......
...@@ -380,17 +380,18 @@ class DbSvc(BaseSvc): ...@@ -380,17 +380,18 @@ class DbSvc(BaseSvc):
query = '' query = ''
if "where" in self._vars: if "where" in self._vars:
query = self._encode_query(self._list(self._vars["where"])) query = self._encode_query(self._list(self._vars["where"]))
# handle paging options (see Ext.PagingToolbar) # 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: if 'start' in self._vars and 'limit' in self._vars:
kwargs['limitby'] = (int(self._vars.start), int(self._vars.limit)) kwargs['limitby'] = (int(self._vars.start), int(self._vars.limit))
results = self._db(self._db[table].id).count()
# proceed the select
rows = self._db(query).select(*fields, **kwargs) rows = self._db(query).select(*fields, **kwargs)
self._debug("End DbSvc.read") self._debug("End DbSvc.read")
return {"success": True, "data": rows_serializer(rows)} return {"success": True, "results": results, "data": rows_serializer(rows)}
def select(self): def select(self):
......
...@@ -70,8 +70,10 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { ...@@ -70,8 +70,10 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, {
// the columns model // the columns model
this.columns = this.model.colModel; this.columns = this.model.colModel;
// empty top toolbar -- require by the toolbar plugin // empty top toolbar/bottomnar -- required by the plugins
this.tbar = []; this.tbar = [];
this.bbar = new Ext.PagingToolbar();
this.bbar.hide();
// initialize the underlying class. DON'T MOVE // initialize the underlying class. DON'T MOVE
App.grid.Grid.superclass.initComponent.call(this); App.grid.Grid.superclass.initComponent.call(this);
......
/**
* 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);
...@@ -152,6 +152,7 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, { ...@@ -152,6 +152,7 @@ App.data.JsonStore = Ext.extend(Ext.data.Store, {
this.reader = new Ext.data.JsonReader({ this.reader = new Ext.data.JsonReader({
root: 'data', root: 'data',
fields: this.model.fields, fields: this.model.fields,
totalProperty: 'results',
idProperty: this.model.idProperty, idProperty: this.model.idProperty,
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment