/*
- * (c) 2005-2009 Richard Cowin (http://openrico.org)
- * (c) 2005-2009 Matt Brown (http://dowdybrown.com)
+ * (c) 2005-2011 Richard Cowin (http://openrico.org)
+ * (c) 2005-2011 Matt Brown (http://dowdybrown.com)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
if (!Rico.Buffer) Rico.Buffer = {};
-Rico.Buffer.AjaxXML = function(url,options,ajaxOptions) {
+Rico.Buffer.AjaxLoadOnce = function(url,options,ajaxOptions) {
this.initialize(url,options,ajaxOptions);
}
-Rico.Buffer.AjaxXML.prototype = {
+Rico.Buffer.AjaxLoadOnce.prototype = {
/**
* @class Implements buffer for LiveGrid. Loads data from server via a single AJAX call.
* @extends Rico.Buffer.Base
Rico.Buffer.AjaxXMLMethods = {
-/** @lends Rico.Buffer.AjaxXML# */
+/** @lends Rico.Buffer.AjaxLoadOnce# */
fetch: function(offset) {
if (this.fetchData) {
this.foundRowCount=true;
page_size: (typeof fetchSize=='number') ? fetchSize : this.totalRows,
offset: startPos.toString()
};
- if (!this.foundRowCount) queryHash['get_total']='true';
+ queryHash[this.liveGrid.actionId]="query";
if (this.options.requestParameters) {
for ( var i=0; i < this.options.requestParameters.length; i++ ) {
var anArg = this.options.requestParameters[i];
delete this.timeoutHandler;
},
- // used by both XML and SQL buffers
+ // used by both LoadOnce and SQL buffers
jsUpdate: function(startPos, newRows, newStyle, totalRows, errMsg) {
this.clearTimer();
this.processingRequest=false;
}
},
- // used by both XML and SQL buffers
+ // used by both LoadOnce and SQL buffers
ajaxUpdate: function(startPos,xhr) {
this.clearTimer();
this.processingRequest=false;
this.liveGrid.showMsg(Rico.getPhraseById("httpError",xhr.status));
return;
}
+ Rico.log("ajaxUpdate: startPos="+startPos);
this._responseHandler=this['processResponse'+this.options.fmt.toUpperCase()];
if (!this._responseHandler(startPos,xhr)) return;
if (this.options.onAjaxUpdate)
}
},
- // used by both XML and SQL buffers
+ // used by both LoadOnce and SQL buffers
processResponseXML: function(startPos,request) {
// The response text may contain META DATA for debugging if client side debugging is enabled in VS\r
var xmlDoc = request.responseXML;\r
},
dom2jstableStyle: function(rowsElement,firstRow) {
- var acceptStyle=this.options.acceptStyle;
Rico.log("dom2jstableStyle start");
var newRows = [];
var trs = rowsElement.getElementsByTagName("tr");
return true;
},
- // specific to XML buffer
+ // specific to LoadOnce buffer
updateBuffer: function(start, newRows, newStyle) {
this.baseRows = newRows;
this.attr = newStyle;
this.startPos = 0;
},
- // used by both XML and SQL buffers
+ // used by both LoadOnce and SQL buffers
updateGrid: function(offset) {
Rico.log("updateGrid, size="+this.size+' rcv cnt type='+typeof(this.rowcntContent));
var newpos;
this.setTotalRows(eofrow);
newpos=Math.min(this.liveGrid.topOfLastPage(),offset);
Rico.log("updateGrid: new rowcnt="+eofrow+" newpos="+newpos);
- if (lastTotalRows==0 && this.liveGrid.sizeTo=='data')
- Rico.runLater(100,this.liveGrid,'adjustPageSize'); // FF takes a long time to calc initial size
this.liveGrid.scrollToRow(newpos);
if ( this.isInRange(newpos) ) {
this.liveGrid.refreshContents(newpos);
Rico.Buffer.AjaxSQL.prototype = {
/**
* @class Implements buffer for LiveGrid. Loads data from server in chunks as user scrolls through the grid.
- * @extends Rico.Buffer.AjaxXML
+ * @extends Rico.Buffer.AjaxLoadOnce
* @constructs
*/
initialize: function(url,options,ajaxOptions) {
- Rico.extend(this, new Rico.Buffer.AjaxXML());
+ Rico.extend(this, new Rico.Buffer.AjaxLoadOnce());
Rico.extend(this, Rico.Buffer.AjaxSQLMethods);
this.dataSource=url;
this.options.canFilter=true;
this.options.largeBufferSize = 7.0; // 7 pages
this.options.nearLimitFactor = 1.0; // 1 page
+ this.options.canRefresh=true;
Rico.extend(this.options, options || {});
Rico.extend(this.ajaxOptions, ajaxOptions || {});
}
formQueryHashSQL: function(startPos,fetchSize,fmt) {
var queryHash=this.formQueryHashXML(startPos,fetchSize);
- queryHash[this.liveGrid.actionId]="query";
+ if (!this.foundRowCount) queryHash['get_total']='true';
if (fmt) queryHash._fmt=fmt;
// sort
queryHash['f['+colnum+'][len]']=c.filterValues.length;
for (var i=0; i<c.filterValues.length; i++) {
var fval=c.filterValues[i];
- if (c.filterOp=='LIKE' && fval.indexOf('*')==-1) fval='*'+fval+'*';
+ if (c.format.type == 'date') {
+ var parts = fval.split('.');
+ if (parts.length > 1) {
+ parts.reverse();
+ for (var j=0; j < parts.length; j++)
+ if (parts[j].length == 1)
+ parts[j] = '0' + parts[j].toString();
+ fval = parts.join('-');
+ }
+ }
+ if (c.filterOp=='LIKE' && fval.indexOf('*')==-1) {
+ if (c.format.filterUI.charAt(1) == '^') fval=fval+'*';
+ else if (c.format.filterUI.charAt(1) == '$') fval='*'+fval;
+ else fval='*'+fval+'*';
+ }
queryHash['f['+colnum+']['+i+']']=fval;
}
}
this.startPos = start;
} else {
this.rows = this.rows.concat( newRows.slice(0, newRows.length));
- if (this.attr) this.attr = this.attr.concat( newStyle.slice(0, newStyle.length));
+ if (this.attr && newStyle) this.attr = this.attr.concat( newStyle.slice(0, newStyle.length));
if (this.rows.length > this.maxBufferSize) {
var fullSize = this.rows.length;
this.rows = this.rows.slice(this.rows.length - this.maxBufferSize, this.rows.length);