Author: abelevich
Date: 2007-05-24 14:34:56 -0400 (Thu, 24 May 2007)
New Revision: 874
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Log:
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-24
18:34:31 UTC (rev 873)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-24
18:34:56 UTC (rev 874)
@@ -203,8 +203,6 @@
var totalWidth = this.grid.getColumnsTotalWidth();
this.scrollBox.moveTo(0, 0);
- this.scrollBox.setWidth(this.getWidth()+1);
- this.scrollBox.setHeight(this.getHeight()+1);
this.scrollBox.setWidth(this.getWidth());
this.scrollBox.setHeight(this.getHeight());
@@ -229,12 +227,16 @@
this.frozenContentBox.setWidth(frozenContentWidth);
this.frozenContentBox.setHeight(height - fixH);
+ this.scrollBox.setWidth(this.getWidth()+1);
+ this.scrollBox.setHeight(this.getHeight()+1);
+ this.scrollBox.setWidth(this.getWidth());
+ this.scrollBox.setHeight(this.getHeight());
+
var scrollPos = Math.min(totalWidth - frozenContentWidth - this.contentBox.getWidth(),
scrollLeft);
this.grid.adjustScrollPosition(scrollPos);
this.dataVisible = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) +
1;
this.dataVisible = Math.min(this.dataVisible, this.rowsCount);
- //this.dataVisible = this.rowsCount;
if(height > 0) {
this.adjustDataPosition(this.currentPos);
}
@@ -253,9 +255,9 @@
return;
}
- // 1. calculate direction and range to load next data
+ // 1. calculate direction and range to load next data
+ this.processedPos = pos;
var forwardDir = (this.currentPos <= pos) ? true : false;
- this.currentPos = pos;
// first visible row index
var first = parseInt(pos / this.defaultRowHeight) - 1;
@@ -277,6 +279,7 @@
task.from = from;
task.to = to;
task.first = first;
+ task.pos = pos;
this._setPendingTask(task);
}
},
@@ -288,13 +291,15 @@
rowsToLoadIdx: [],
from: 0,
to: 0,
- first: 0
+ first: 0,
+ pos: 0
};
}
return this.pendingTask;
},
_setPendingTask: function(task) {
clearTimeout(this.pendingTask.timer);
+ this.pendingTask.timer = null;
this.pendingTask = task;
// and plan other agjusting over the time
@@ -325,15 +330,19 @@
});
},
startLoadData: function() {
- if(this.updateStarted) return;
+ if(this.updateStarted) {
+ this._setPendingTask(this._getPendingTask());
+ return;
+ }
+
+ this.updateStarted = true;
+ this.taskStartTime = (new Date()).getTime();
- this.taskStartTime = (new Date()).getTime();
-
var task = this._getPendingTask();
var range = $R(task.from, task.to);
var switchType = 5;
var startIndex = 0;
- var startRow = 0;
+ var startRowIndx = 0;
var countToLoad = 0;
// if we have intersepted ranges than rearrange rows
@@ -344,7 +353,7 @@
}
if(switchType === 0) {
- startRow = this.templFrozen.getElement().rows[0].index;
+ startRowIndx = this.templFrozen.getElement().rows[0].index;
startIndex = range.start;
countToLoad = range.end - range.start;
}
@@ -358,7 +367,7 @@
switchType = 1;
countToLoad = range.start - this.currRange.start;
if(countToLoad > 0) {
- startRow = frozenTbl.rows[0].index;
+ startRowIndx = frozenTbl.rows[0].index;
startIndex = this.currRange.end;
}
}
@@ -368,7 +377,7 @@
if(countToLoad > 0) {
startIndex = range.start;
var restCount = this.rowsCount - countToLoad;
- startRow = frozenTbl.rows[restCount].index;
+ startRowIndx = frozenTbl.rows[restCount].index;
}
}
}
@@ -383,28 +392,31 @@
if(countToLoad > 0 && process) {
this.updateStarted = true;
ClientUILib.log(ClientUILogger.WARNING, "Start loading...");
+ this.currRange = range;
+ this.currentPos = task.pos;
+
+ this.taskDefineTime = (new Date()).getTime();
+
this.showSplash();
- this.taskDefineTime = (new Date()).getTime();
- var task = this._getPendingTask();
// Make timer to handle quick clicks on scrollbar arrows
- task.timer = setTimeout(function() {
+ setTimeout(function() {
// 4. start data loading
//this.container.hide();
- //Element.setStyle(this.container.getElement(), {visibility: "hidden"});
-
- screen.updateInterval = 1000;
+ this.updateInterval = screen.updateInterval;
+ screen.updateInterval = 500;
this.grid.dataModel.loadRows({
index: startIndex,
count: countToLoad,
- startRow: startRow,
+ startRow: startRowIndx,
switchType: switchType});
-
- this.currRange = range;
}.bind(this), 10);
}
+ else {
+ this.updateStarted = false;
+ }
},
setProgressCtrl: function(ctrl) {
@@ -426,93 +438,113 @@
* @param {Object} options
*/
invalidate: function(options) {
-
- //Element.setStyle(this.container.getElement(), {visibility: "inherit"});
- //this.container.show();
-
+
ClientUILib.log(ClientUILogger.WARNING, "Stop loading.");
var frozenTbl = this.templFrozen.getElement();
var normalTbl = this.templNormal.getElement();
- if(options.switchType === 0) {
- var pos = this.defaultRowHeight * options.index;
- this.templFrozen.moveToY(pos);
- this.templNormal.moveToY(pos);
- }
- else if(options.switchType === 1 || options.switchType === 2) {
- // store visible row pos to restore after rows reerrange
- var visibleRowPos = 0;
- var count = frozenTbl.rows.length;
- var frows = new Array(count), nrows = new Array(count);
- var j = 0;
-
- if(options.switchType === 1) {
- visibleRowPos = this.templFrozen.getY() + options.count * this.defaultRowHeight;
- for(i=options.count; i<this.rowsCount; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+ screen.updateInterval = this.updateInterval;
+ //this.container.show();
+
+ setTimeout(function (){
+ if(options.switchType === 0) {
+ var visibleRowPos = this.defaultRowHeight * options.index;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ }
+ else if(options.switchType === 1 || options.switchType === 2) {
+ // store visible row pos to restore after rows reerrange
+ var count = frozenTbl.rows.length;
+ var frows = new Array(count), nrows = new Array(count);
+ var j = 0;
+
+ if(options.switchType === 1) {
+ for(i=options.count; i<this.rowsCount; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+ for(i=0; i<options.count; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
}
- for(i=0; i<options.count; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+ else {
+ for(i=this.rowsCount - options.count; i<this.rowsCount; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+ for(i=0; i<this.rowsCount - options.count; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
}
- }
- else {
- visibleRowPos = options.index * this.defaultRowHeight;
- for(i=this.rowsCount - options.count; i<this.rowsCount; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+
+
+ // Mozilla is faster when doing the DOM manipulations on
+ // an orphaned element. MSIE is not
+ var removeChilds = navigator.product == "Gecko";
+ var fbody = frozenTbl.tBodies[0];
+ var nbody = normalTbl.tBodies[0];
+ var fnextSibling = fbody.nextSibling;
+ var nnextSibling = nbody.nextSibling;
+
+ if (removeChilds) { // remove all rows
+ fp = fbody.parentNode;
+ fp.removeChild(fbody);
+ np = nbody.parentNode;
+ np.removeChild(nbody);
}
- for(i=0; i<this.rowsCount - options.count; i++) {
- frows[j] = frozenTbl.rows[i];
- nrows[j] = normalTbl.rows[i];
- j++;
+
+ if(options.switchType === 2) {
+ var visibleRowPos = options.index * this.defaultRowHeight;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
}
+
+ // insert in the new order
+ for (i = 0; i < count; i++) {
+ fbody.appendChild(frows[i]);
+ nbody.appendChild(nrows[i]);
+ }
+
+ if(removeChilds) {
+ fp.insertBefore(fbody, fnextSibling);
+ np.insertBefore(nbody, nnextSibling);
+ }
+
+ if(options.switchType === 1) {
+ var visibleRowPos = this.currRange.start * this.defaultRowHeight;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ }
}
+ this.splash.hide();
+ this.updateStarted = false;
- // Mozilla is faster when doing the DOM manipulations on
- // an orphaned element. MSIE is not
- var removeChilds = navigator.product == "Gecko";
- var fbody = frozenTbl.tBodies[0];
- var nbody = normalTbl.tBodies[0];
- var fnextSibling = fbody.nextSibling;
- var nnextSibling = nbody.nextSibling;
-
- if (removeChilds) { // remove all rows
- fp = fbody.parentNode;
- fp.removeChild(fbody);
- np = nbody.parentNode;
- np.removeChild(nbody);
- }
+ }.bind(this), 10);
+
- if(options.switchType === 2) {
- this.templFrozen.moveToY(visibleRowPos);
- this.templNormal.moveToY(visibleRowPos);
- }
-
- // insert in the new order
- for (i = 0; i < count; i++) {
- fbody.appendChild(frows[i]);
- nbody.appendChild(nrows[i]);
- }
-
- if(removeChilds) {
- fp.insertBefore(fbody, fnextSibling);
- np.insertBefore(nbody, nnextSibling);
- }
-
- if(options.switchType === 1) {
- this.templFrozen.moveToY(visibleRowPos);
- this.templNormal.moveToY(visibleRowPos);
- }
+ if(this.processedPos != this.currentPos) {
+ this.currentPos = this.processedPos;
+ setTimeout(function (){
+ this.pendedUpdate();
+ }.bind(this), this.grid.dataModel.getRequestDelay());
}
-
- screen.updateInterval = 0;
- this.splash.hide();
- this.updateStarted = false;
+ },
+ pendedUpdate: function() {
+ if(this.processedPos != this.currentPos) {
+ this.currentPos = this.processedPos;
+ setTimeout(function (){
+ this.pendedUpdate();
+ }.bind(this), this.grid.dataModel.getRequestDelay());
+ }
+ else {
+ this.adjustDataPosition(this.processedPos);
+ }
}
});
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-24
18:34:31 UTC (rev 873)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-24
18:34:56 UTC (rev 874)
@@ -229,7 +229,7 @@
agjustSeparators: function() {
var offset = 0;
var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
- for(var i=0; i<this._columns.length; i++) {
+ for(var i=0; i<this._columns.length - 1; i++) {
if(i == fcnt) offset = 0;
offset += this._columns[i].width;
this._columns[i].sep.moveToX(offset - 4);