Author: dmorozov
Date: 2007-06-22 12:52:30 -0400 (Fri, 22 Jun 2007)
New Revision: 1278
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
Log:
1. Create 2 custom events for grid: OnPostScroll & OnPostSort
2. Fix problem with selection manager state restoring - put it into correct place.
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-22
15:52:41 UTC (rev 1277)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-22
16:52:30 UTC (rev 1278)
@@ -188,7 +188,7 @@
},
AJAX : {
- updateRows: function(options,request,grid,clientid, callbacks){
+ updateRows: function(options,request,grid,clientid, callbacks, callbacksPost){
var localOptions = options;
var rowCount = grid.getBody().templFrozen.getElement().rows.length;
var startRow = localOptions.startRow;
@@ -227,7 +227,15 @@
callback.call(grid, rowsForUpdate[i][":n:"]);
}
);
- }
+ }
+
+ if(callbacksPost) {
+ callbacksPost.unbreakableEach(
+ function(callback) {
+ callback.call(grid);
+ }
+ );
+ }
}, 100);
}
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-06-22
15:52:41 UTC (rev 1277)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-06-22
16:52:30 UTC (rev 1278)
@@ -8,7 +8,16 @@
});
Object.extend(ClientUI.controls.grid.ScrollableGrid.prototype, {
+ /**
+ * Occured when scroll position adjusted
+ */
+ eventOnPostScroll: {},
+ /**
+ * Occured when sorting adjusted
+ */
+ eventOnPostSort: {},
+
initialize: function(options) {
this.options = options;
@@ -25,6 +34,9 @@
];
this.init2 = this.init.bindAsEventListener(this);
+ this.eventOnPostSort = new ClientUI.common.utils.CustomEvent('OnSort');
+ this.eventOnPostScroll = new ClientUI.common.utils.CustomEvent('OnScroll');
+
this.startUpTime = new Date().getTime();
this.rowCallbacks = [];
@@ -54,22 +66,25 @@
onSortComplete : function(request, event, data){
var options = request.getJSON("options");
- Utils.AJAX.updateRows(options,request,this,this.client_id,
[this.updateSelectionCallBack]);
- if (this.selectionManager) {
- setTimeout(function(){
- this.selectionManager.restoreState();
- }.bind(this), 500);
- }
+ Utils.AJAX.updateRows(options,request,
+ this,this.client_id,
+ [this.updateSelectionCallBack],
+ [function(){
+ this.selectionManager.restoreState();
+ this.eventOnPostSort.fire(options.column, options.order);
+ }]);
},
onScrollComplete : function(request, event, data){
var options = this.dataModel.getCurrentOptions();
window.loadingServerTime = (new Date()).getTime();
- Utils.AJAX.updateRows(options,request,this,this.client_id,
[this.updateSelectionCallBack]);
- if (this.selectionManager) {
- setTimeout(function(){
- this.selectionManager.restoreState();
- }.bind(this), 500);
- }
+ Utils.AJAX.updateRows(options,request,
+ this,this.client_id,
+ [this.updateSelectionCallBack],
+ [function(){
+ this.selectionManager.restoreState();
+ this.eventOnPostScroll.fire(this.getBody().currRange.start);
+ }]);
+
window.loadingEndTime = (new Date()).getTime();
// TODO: remove this time statistic logging