Author: dmorozov
Date: 2007-06-20 13:15:45 -0400 (Wed, 20 Jun 2007)
New Revision: 1239
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
trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
Log:
Improve performance under IE while DOM update.
Fix problem with update while scrolling when cells contain tables inside.
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-20
15:07:36 UTC (rev 1238)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/utils/Utils.js 2007-06-20
17:15:45 UTC (rev 1239)
@@ -47,28 +47,30 @@
if (ClientUILib.isIE) {
var theDoc = document;
var createEl = theDoc.createElement;
+
var row = target.cloneNode(false);
-
this._clearAttributes(row);
this.copyAttributes(row, src);
- var tds = [];
- var i = 0;
- var pattern = '(?:<td.*?>)((\n|\r|.)*?)(?:<\/td>)';
- var rez = src.xml.gsub(pattern, function(item) {
- tds[i++] = item[1];
- return ""; });
-
-
- var count = i, td;
- for(i=0; i< count; i++) {
- td = createEl("TD");
- td.innerHTML = tds[i];
- td.className = "ClientUI_Grid_BC";
- row.insertBefore(td, null);
- }
+ var tdNode, tdSrc;
+ var childs = src.childNodes;
+ var count = childs.length;
+ var innerHTML, j, innerCount;
+ for(var i=0; i<count; i++) {
+ tdSrc = childs[i];
+ tdNode = createEl( "TD" );
+ //this.copyAttributes(tdNode, tdSrc);
+ tdNode.className = "ClientUI_Grid_BC";
+ row.insertBefore(tdNode, null); // insertBefore MUCH FASTER then AppendChild !!!
+
+ innerHTML = [];
+ innerCount = tdSrc.childNodes.length;
+ for(j=0; j<innerCount; j++) {
+ innerHTML.push(tdSrc.childNodes[j].xml);
+ }
+ tdNode.innerHTML = innerHTML.join();
+ }
target.parentNode.replaceChild(row, target);
-
return row;
} else {
@@ -177,8 +179,6 @@
AJAX : {
updateRows: function(options,request,grid,clientid, callbacks){
- var theDoc = document;
- var getEl = theDoc.getElementById;
var localOptions = options;
var rowCount = grid.getBody().templFrozen.getElement().rows.length;
var startRow = localOptions.startRow;
@@ -187,30 +187,40 @@
var dataModel = grid.dataModel;
var baseid = clientid;
+ var rowsForUpdate = callbacks ? new Array(count) : null;
+
for(i=0; i<count; i++) {
rowindex = startRow + i;
if(rowindex >= rowCount){
rowindex -= rowCount;
- }
+ }
[":f:", ":n:"].unbreakableEach(
function(suffix) {
var id = baseid + suffix + rowindex;
var row = Utils.DOM.replaceNode(id, request);
if (callbacks) {
- callbacks.unbreakableEach(
- function(callback) {
- callback.call(grid, {index : rowindex, row : row});
- }
- );
+ // just suspend operation for future
+ if(!rowsForUpdate[i]) rowsForUpdate[i] = {};
+ rowsForUpdate[i][suffix] = {index : rowindex, row : row};
}
-
-
}
);
-
-
}
+
+ if (callbacks) {
+ // process suspended processing
+ setTimeout(function(){
+ for(var i=0; i<count; i++) {
+ callbacks.unbreakableEach(
+ function(callback) {
+ callback.call(grid, rowsForUpdate[i][":f:"]);
+ callback.call(grid, rowsForUpdate[i][":n:"]);
+ }
+ );
+ }
+ }, 100);
+ }
dataModel.eventDataReady.fire(localOptions);
}
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-20
15:07:36 UTC (rev 1238)
+++
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-06-20
17:15:45 UTC (rev 1239)
@@ -56,7 +56,9 @@
var options = request.getJSON("options");
Utils.AJAX.updateRows(options,request,this,this.client_id,
[this.updateSelectionCallBack]);
if (this.selectionManager) {
- this.selectionManager.restoreState();
+ setTimeout(function(){
+ this.selectionManager.restoreState();
+ }.bind(this), 500);
}
},
Modified:
trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-06-20
15:07:36 UTC (rev 1238)
+++
trunk/sandbox/scrollable-grid/src/main/resources/org/richfaces/renderkit/html/css/grid.xcss 2007-06-20
17:15:45 UTC (rev 1239)
@@ -259,8 +259,8 @@
-moz-outline: none;
-moz-user-focus: normal;
cursor: default;
- height:21px !important;
- border-right: 1px solid #f1efe2;
+ border-right: 1px solid #f1efe2;
+ border-bottom: 1px solid #f1efe2;
}
.ClientUI_Grid_BCIndex {
background-color: #ebeadb;
@@ -279,11 +279,10 @@
*/
.ClientUI_Grid_BR {
font: normal 8pt arial;
- border-bottom: 1px solid #f1efe2;
white-space: nowrap;
- height:21px;
box-sizing: border-box;
-moz-box-sizing: border-box;
+ height:21px !important;
}
.idg-row-selected-h {
@@ -297,14 +296,12 @@
.ClientUI_Grid_BROdd {
background-color: #FFFFFF;
font: normal 8pt arial;
- height: 22px;
z-index:2;
}
.ClientUI_Grid_BREven {
background-color: #fcfaf6;
font: normal 8pt arial;
- height: 22px;
z-index:2;
}
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
===================================================================
---
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-06-20
15:07:36 UTC (rev 1238)
+++
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-06-20
17:15:45 UTC (rev 1239)
@@ -12,11 +12,11 @@
<td class="ClientUI_Grid_BC Idg-column-cell #{columnClass}
#{component.attributes['styleClass']}"
id="#{client_id}:c_#{cell_id}">
- <span id="#{client_id}:bc_#{cell_index}"
class="ClientUI_Grid_BCBody1">
- <span class="ClientUI_Grid_BCBody"
id="#{client_id}:bc_#{cell_id}">
+ <div id="#{client_id}:bc_#{cell_index}"
class="ClientUI_Grid_BCBody1">
+ <div class="ClientUI_Grid_BCBody"
id="#{client_id}:bc_#{cell_id}">
<vcp:body/>
- </span>
- </span>
+ </div>
+ </div>
</td>
-</f:root>
\ No newline at end of file
+</f:root>
\ No newline at end of file