Author: konstantin.mishin
Date: 2007-10-23 05:23:07 -0400 (Tue, 23 Oct 2007)
New Revision: 3480
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
Log:
RF-1118
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2007-10-23
01:15:48 UTC (rev 3479)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/component/UIScrollableDataTable.java 2007-10-23
09:23:07 UTC (rev 3480)
@@ -382,4 +382,8 @@
}
//super.setRowIndex(index);
}
+
+ public void resetReqRowsCount() {
+ this.reqRowsCount = -1;
+ }
}
Modified:
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java
===================================================================
---
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java 2007-10-23
01:15:48 UTC (rev 3479)
+++
trunk/ui/scrollableDataTable/src/main/java/org/richfaces/renderkit/html/ScrollableDataTableBaseRenderer.java 2007-10-23
09:23:07 UTC (rev 3480)
@@ -574,9 +574,11 @@
Map parameters = externalContext.getRequestParameterMap();
String s_id = clientId + ":si";
+ grid.resetReqRowsCount();
if(parameters.containsKey(s_id)){
String options = (String)parameters.get(s_id);
grid.setScrollPos(options);
+ grid.setFirst(Integer.parseInt(options.split(",")[1]));
}
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-10-23
01:15:48 UTC (rev 3479)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-10-23
09:23:07 UTC (rev 3480)
@@ -83,7 +83,7 @@
this.adjustDataPosition(ypos);
},
createControl: function(template) {
-
+ this.scrollInput = $(this.gridId + ":si");
var childs = template.childNodes;
for(var i=0; i<childs.length; i++) {
if(childs[i].id == this.gridId + ":bc") {
@@ -383,6 +383,8 @@
var startRowIndx = 0;
var countToLoad = 0;
+ this.scrollInput.value = task.pos + "," + range.start + "," +
range.end;
+
// if we have intersepted ranges than rearrange rows
// in other case just move rows table to first position
if(this.currRange.end < range.start
@@ -791,5 +793,20 @@
} else {
return 16;
}
+ },
+
+ restoreScrollState: function() {
+ var value = this.scrollInput.value
+ if(value !=''){
+ var values = value.split(',');
+ this.scrollBox.getElement().scrollTop = values[0];
+ this.currentPos = values[0];
+ this.currRange.start = values[1];
+ this.currRange.end = values[2];
+ this._onContentVScroll(values[0]);
+ var visibleRowPos = this.currRange.start * this.defaultRowHeight;
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ }
}
});
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
---
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-10-23
01:15:48 UTC (rev 3479)
+++
trunk/ui/scrollableDataTable/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-10-23
09:23:07 UTC (rev 3480)
@@ -24,7 +24,6 @@
this.options = options;
this.client_id = this.options.client_id;
this.rows_count = $(this.client_id + "_rows_input").value;
- this.scroll_si = $(this.client_id + ":si");
this.columns_count = this.options.columnsCount;
this.splash_id = this.options.splash_id;
this.dataModel = new ClientUI.controls.grid.FakeArrayDataModel(this.rows_count,
this.columns_count, this.client_id);
@@ -77,26 +76,8 @@
this.endPostProcessTime = (new Date()).getTime();
}.bind(this), 500);
-
- if(this.scroll_si.value !=''){
- var options = this.scroll_si.value.split(',');
- this.restoreScrollState(options[0],options[1],options[2]);
- }
-
- var form = this.getForm($(this.client_id));
- Event.observe(form,
"submit",this.restoreScrollPos.bindAsEventListener(this));
+ this.getBody().restoreScrollState();
}
- },
-
- getForm: function(element){
- var node = element;
- if(node){
- while(node.tagName.toUpperCase() != 'FORM'){
- node = node.parentNode;
- }
- }
-
- return node;
},
onSortComplete : function(request, event, data){
@@ -167,33 +148,6 @@
this.getBody().hideColumn(index, frozen);
if(this.getFooter()) {this.getFooter().hideColumn(index, frozen);}
this.updateLayout();
- },
-
- restoreScrollState: function(scrollPos, start, end) {
-
- var body = this.getBody();
- body.scrollBox.getElement().scrollTop = scrollPos;
- body.currentPos = scrollPos;
- body.currRange.start = start;
- body.currRange.end = end;
- body._onContentVScroll(scrollPos);
- var visibleRowPos = body.currRange.start * body.defaultRowHeight;
- //setTimeout(function(){
- body.templFrozen.moveToY(visibleRowPos);
- body.templNormal.moveToY(visibleRowPos);
- //}, 500);
- },
-
- getScrollPos: function() {
- return this.getBody().currentPos;
- },
-
- restoreScrollPos: function(){
- var body = this.getBody();
- var start = body.currRange.start;
- var end = body.currRange.end;
- var index = this.getScrollPos();
- this.scroll_si.value = index + "," + start + "," + end;
}
});