[richfaces-svn-commits] JBoss Rich Faces SVN: r723 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu May 10 14:22:20 EDT 2007


Author: abelevich
Date: 2007-05-10 14:22:20 -0400 (Thu, 10 May 2007)
New Revision: 723

Modified:
   trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.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-10 18:22:06 UTC (rev 722)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js	2007-05-10 18:22:20 UTC (rev 723)
@@ -77,7 +77,7 @@
 	_onDataReady: function(options) {
 		// load rows data		
 		var currTime = (new Date()).getTime();
-		
+		/*
 		var loadRow = this.loadRow.bind(this);
 		var byIndex = options.indexes!==null;
 		var count = options.indexes!==null ? options.indexes.length : (options.ids!==null?options.ids.lenth : 0);
@@ -91,12 +91,13 @@
 		if(ClientUILib.isIE && !ClientUILib.isIE7) {
 			this.setScrollPos(this.currentPos);
 			this.adjustScrollPosition(this.grid.getColumnScrollX());
-		}
-		
-		ClientUILib.log(ClientUILogger.WARNING, "data for "+count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+		}		
+		*/
+
+		ClientUILib.log(ClientUILogger.WARNING, "data for "+options.count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");		
+		ClientUILib.log(ClientUILogger.WARNING, "start index: " + options.index + ", and startRow: " + options.startRow);
 		ClientUILib.log(ClientUILogger.WARNING, "load data delta time: " + (this.taskStartTime - this.taskDefineTime));
 		ClientUILib.log(ClientUILogger.WARNING, "data prepare time: " + (this.taskStartLoadingTime - this.taskStartTime));
-		ClientUILib.log(ClientUILogger.INFO, "Load data indexes: " + options.ids.inspect());
 	},
 	registerEvents: function() {
 		Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
@@ -185,7 +186,11 @@
 		for(var i=0; i<this.rowsCount; i++) {
 			templFrozen.rows[i].index = i;
 			templNormal.rows[i].index = i;
-		}		
+		}
+		this.countToLoad = 0;
+		this.startRow = 0;
+		this.startIndex = 0;	
+		
 		return true;		
 	},
 	updateColumns: function() {
@@ -533,7 +538,7 @@
 		}
 		return this.pendingTask;
 	},	
-	_setPendingTask: function(task) {
+	_setPendingTask: function(task) {	
 		// and plan other agjusting over the time
 		this.taskDefineTime = (new Date()).getTime();
 		task.timer = setTimeout(function() {
@@ -554,29 +559,34 @@
 				switchRows = false;
 			}
 			
+			this.startIndex = range.start;
+			this.countToLoad = range.end - range.start;
+			
 			if(!switchRows) {
+				this.startRow = this.templFrozen.getElement().rows[0].index;
+				
 				this.prepareRows(0, range.end - range.start);
 				var pos = this.defaultRowHeight * range.start;
 				this.templFrozen.moveToY(pos);
 				this.templNormal.moveToY(pos);
 			}
 			else {
-				var count = 0, i, row, rownew;
-				
+				var i, row, rownew;
+				this.countToLoad = 0;
 				var frozenTbl = this.templFrozen.getElement().tBodies[0];
 				var normalTbl = this.templNormal.getElement().tBodies[0];
-				
 				if(range.start > this.currRange.start 
-					&& range.start < this.currRange.end) {
+					&& range.start < this.currRange.end) {					
 					// TODO: get rows from this.currRange.start to range.start
 					// and move them to end of table
 					// then move table to correct position
-					count = range.start - this.currRange.start;
+					this.countToLoad = range.start - this.currRange.start;
+					this.startRow = frozenTbl.rows[0].index;
 					
 					// store visible row pos to restore after rows reerrange
-					var visibleRowPos = this.templFrozen.getY() + count * this.defaultRowHeight;
+					var visibleRowPos = this.templFrozen.getY() + this.countToLoad * this.defaultRowHeight;
 					
-					for(i=0; i<count; i++) {
+					for(i=0; i<this.countToLoad; i++) {
 						row = frozenTbl.rows[0];
 						frozenTbl.deleteRow(row);
 						rownew = frozenTbl.insertRow(this.rowsCount-1);
@@ -589,7 +599,7 @@
 					}
 					
 					this.templFrozen.moveToY(visibleRowPos);
-					this.templNormal.moveToY(visibleRowPos);					
+					this.templNormal.moveToY(visibleRowPos);
 /*
 	// prepare array of column elements for sorting
 	var count = this.body.rows.length;
@@ -664,6 +674,13 @@
 				indexes: rowsToLoadIdx,
 				ids: rowsToLoad});
 			*/
+
+			this.taskStartLoadingTime = (new Date()).getTime();
+			// 4. start data loading
+			this.grid.dataModel.loadRows({
+				index: this.startIndex,
+				count: this.countToLoad,
+				startRow: this.startRow});
 				
 			clearTimeout(task.timer);
 			task.timer = null;




More information about the richfaces-svn-commits mailing list