this.ajaxOptions.onComplete = function(xhr) { self.ajaxUpdate(offset,xhr); };
new Rico.ajaxRequest(this.dataSource, this.ajaxOptions);
} else {
- this.ajaxOptions.onComplete = function(newRows, newAttr, totalRows, errMsg) { self.jsUpdate(offset, newRows, newAttr, totalRows, errMsg); };
+ this.ajaxOptions.onComplete = function(newRows, newStyle, totalRows, errMsg) { self.jsUpdate(offset, newRows, newStyle, totalRows, errMsg); };
this.dataSource(this.ajaxOptions);
}
} else {
},
// used by both XML and SQL buffers
- jsUpdate: function(startPos, newRows, newAttr, totalRows, errMsg) {
+ jsUpdate: function(startPos, newRows, newStyle, totalRows, errMsg) {
this.clearTimer();
this.processingRequest=false;
Rico.log("jsUpdate: "+arguments.length);
this.foundRowCount = true;
Rico.log("jsUpdate: found RowCount="+this.rowcntContent);
}
- this.updateBuffer(startPos, newRows, newAttr);
+ this.updateBuffer(startPos, newRows, newStyle);
if (this.options.onAjaxUpdate)
this.options.onAjaxUpdate();
this.updateGrid(startPos);
// process children of <ajax-response>
var response = xmlDoc.getElementsByTagName("ajax-response");
- if (response == null || response.length != 1) return false;
+ if (response == null || response.length != 1) {
+ alert("Received invalid response from server");
+ return false;
+ }
+ Rico.log("Processing ajax-response");
this.rcvdRows = 0;
this.rcvdRowCount = false;
var ajaxResponse=response[0];
this.rcvdOffset = rowsElement.getAttribute("offset");
Rico.log("ajaxUpdate: rcvdOffset="+this.rcvdOffset);
var newRows = this.dom2jstable(rowsElement);
- var newAttr = (this.options.acceptAttr.length > 0) ? this.dom2jstableAttr(rowsElement) : false;
+ var newStyle = (this.options.acceptStyle) ? this.dom2jstableStyle(rowsElement) : false;
this.rcvdRows = newRows.length;
- this.updateBuffer(startPos, newRows, newAttr);
+ this.updateBuffer(startPos, newRows, newStyle);
return true;
},
+ dom2jstableStyle: function(rowsElement,firstRow) {
+ var acceptStyle=this.options.acceptStyle;
+ Rico.log("dom2jstableStyle start");
+ var newRows = [];
+ var trs = rowsElement.getElementsByTagName("tr");
+ for ( var i=firstRow || 0; i < trs.length; i++ ) {
+ var row = [];
+ var cells = trs[i].getElementsByTagName("td");
+ for ( var j=0; j < cells.length ; j++ ) {
+ row[j]=cells[j].getAttribute('style') || '';
+ }
+ newRows.push( row );
+ }
+ Rico.log("dom2jstableStyle end");
+ return newRows;
+ },
+
processResponseJSON: function(startPos,request) {
var json = Rico.getJSON(request);
if (!json || json == null) {
}
this.rcvdRows = json.rows.length;
- this.updateBuffer(startPos, json.rows);
+ this.updateBuffer(startPos, json.rows, json.styles);
return true;
},
// specific to XML buffer
- updateBuffer: function(start, newRows, newAttr) {
+ updateBuffer: function(start, newRows, newStyle) {
this.baseRows = newRows;
- this.attr = newAttr;
+ this.attr = newStyle;
Rico.log("updateBuffer: # of rows="+this.rcvdRows);
this.rcvdRowCount=true;
this.rowcntContent=this.rcvdRows;
this.pendingRequest=offset;
return;
}
- if (offset < 0) {
+ if ((typeof offset == 'undefined') || (offset < 0)) {
this.clear();
this.setTotalRows(0);
this.foundRowCount = false;
this.ajaxOptions.onComplete = function(xhr) { self.ajaxUpdate(bufferStartPos, xhr); };
new Rico.ajaxRequest(this.dataSource, this.ajaxOptions);
} else {
- this.ajaxOptions.onComplete = function(newRows, newAttr, totalRows, errMsg) { self.jsUpdate(bufferStartPos, newRows, newAttr, totalRows, errMsg); };
+ this.ajaxOptions.onComplete = function(newRows, newStyle, totalRows, errMsg) { self.jsUpdate(bufferStartPos, newRows, newStyle, totalRows, errMsg); };
this.dataSource(this.ajaxOptions);
}
},
return adjustedOffset;
},
- updateBuffer: function(start, newRows, newAttr) {
+ updateBuffer: function(start, newRows, newStyle) {
Rico.log("updateBuffer: start="+start+", # of rows="+this.rcvdRows);
if (this.rows.length == 0) { // initial load
this.rows = newRows;
- this.attr = newAttr;
+ this.attr = newStyle;
this.startPos = start;
} else if (start > this.startPos) { //appending
if (this.startPos + this.rows.length < start) {
this.rows = newRows;
- this.attr = newAttr;
+ this.attr = newStyle;
this.startPos = start;
} else {
this.rows = this.rows.concat( newRows.slice(0, newRows.length));
- if (this.attr) this.attr = this.attr.concat( newAttr.slice(0, newAttr.length));
+ if (this.attr) 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);
}
} else { //prepending
if (start + newRows.length < this.startPos) {
- this.rows = newRows;
+ this.rows = newRows;
+ this.attr = newStyle;
} else {
this.rows = newRows.slice(0, this.startPos).concat(this.rows);
- if (this.maxBufferSize && this.rows.length > this.maxBufferSize)
+ if (newStyle) this.attr = newStyle.slice(0, this.startPos).concat(this.attr);
+ if (this.maxBufferSize && this.rows.length > this.maxBufferSize) {
this.rows = this.rows.slice(0, this.maxBufferSize);
+ if (this.attr) this.attr = this.attr.slice(0, this.maxBufferSize);
+ }
}
this.startPos = start;
}
this.dataSource(this.ajaxOptions);
},
- _jsExport: function(newRows, newAttr, totalRows, errMsg) {
+ _jsExport: function(newRows, newStyle, totalRows, errMsg) {
Rico.log("_jsExport: "+arguments.length);
if (errMsg) {
Rico.log("_jsExport: received error="+errMsg);