[open-ils-commits] r13832 - trunk/Open-ILS/web/js/dojo/openils/widget (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 13 17:08:28 EDT 2009
Author: erickson
Date: 2009-08-13 17:08:22 -0400 (Thu, 13 Aug 2009)
New Revision: 13832
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
Log:
initial pagination support. when enabled, back/prev links appear in a small nav pane just above the grid
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2009-08-13 21:07:02 UTC (rev 13831)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoGrid.js 2009-08-13 21:08:22 UTC (rev 13832)
@@ -1,6 +1,7 @@
if(!dojo._hasResource['openils.widget.AutoGrid']) {
dojo.provide('openils.widget.AutoGrid');
dojo.require('dojox.grid.DataGrid');
+ dojo.require('dijit.layout.ContentPane');
dojo.require('openils.widget.AutoWidget');
dojo.require('openils.widget.AutoFieldWidget');
dojo.require('openils.widget.EditPane');
@@ -22,6 +23,9 @@
selectorWidth : '1.5',
showColumnPicker : false,
columnPickerPrefix : null,
+ displayLimit : 15,
+ displayOffset : 0,
+ showPaginator : false,
/* by default, don't show auto-generated (sequence) fields */
showSequenceFields : false,
@@ -65,6 +69,43 @@
}
);
}
+
+ if(this.showPaginator) {
+ var self = this;
+ this.paginator = new dijit.layout.ContentPane();
+
+
+ var back = dojo.create('a', {
+ innerHTML : 'Back',
+ style : 'padding-right:6px;',
+ href : 'javascript:void(0);',
+ onclick : function() {
+ self.resetStore();
+ self.cachedQueryOpts.offset = self.displayOffset -= self.displayLimit;
+ self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+ }
+ });
+
+ var forw = dojo.create('a', {
+ innerHTML : 'Next',
+ style : 'padding-right:6px;',
+ href : 'javascript:void(0);',
+ onclick : function() {
+ self.resetStore();
+ self.cachedQueryOpts.offset = self.displayOffset += self.displayLimit;
+ self.loadAll(self.cachedQueryOpts, self.cachedQuerySearch);
+ }
+ });
+
+ dojo.place(this.paginator.domNode, this.domNode, 'before');
+ dojo.place(back, this.paginator.domNode);
+ dojo.place(forw, this.paginator.domNode);
+ this.loadProgressIndicator = dojo.create('img', {
+ src:'/opac/images/progressbar_green.gif',
+ style:'height:16px;width:16px;'
+ });
+ dojo.place(this.loadProgressIndicator, this.paginator.domNode);
+ }
},
/* Don't allow sorting on the selector column */
@@ -439,16 +480,28 @@
loadAll : function(opts, search) {
dojo.require('openils.PermaCrud');
- if(!opts) opts = {};
+ if(this.loadProgressIndicator)
+ dojo.style(this.loadProgressIndicator, 'visibility', 'visible');
var self = this;
+ opts = dojo.mixin(
+ {limit : this.displayLimit, offset : this.displayOffset},
+ opts || {}
+ );
opts = dojo.mixin(opts, {
async : true,
streaming : true,
onresponse : function(r) {
var item = openils.Util.readResponse(r);
self.store.newItem(item.toStoreItem());
+ },
+ oncomplete : function() {
+ if(self.loadProgressIndicator)
+ dojo.style(self.loadProgressIndicator, 'visibility', 'hidden');
}
});
+
+ this.cachedQuerySearch = search;
+ this.cachedQueryOpts = opts;
if(search)
new openils.PermaCrud().search(this.fmClass, search, opts);
else
More information about the open-ils-commits
mailing list