You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/01/06 01:10:43 UTC
svn commit: r493265 - /incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
Author: jmargaris
Date: Fri Jan 5 17:10:43 2007
New Revision: 493265
URL: http://svn.apache.org/viewvc?view=rev&rev=493265
Log:
alternate row coloring should behave better now
Modified:
incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
Modified: incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=493265&r1=493264&r2=493265
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js Fri Jan 5 17:10:43 2007
@@ -255,7 +255,6 @@
* with the same sizes. Useful for sorting.
*/
_rebuildRows: function(){
- var alternateRow = false;
if (this.tbody){
this.table.removeChild(this.tbody);
}
@@ -265,13 +264,14 @@
//now populate the body rows
for (var i =0; i<this._rows.length; i++){
- alternateRow = this._rebuildRow(this._rows[i], 0,alternateRow);
+ this._rebuildRow(this._rows[i], 0);
}
window.clearTimeout(this._rebuildRowsTask);
this._rebuildRowsTask = null;
// resize columns in the case of new rows added
this._resizeTableLater ();
+ this._recolorAlternateRows();
},
/**
@@ -343,26 +343,41 @@
_rebuildRow: function( row, depth, alternateRow ){
this.tbody.appendChild(row.domNode);
row.setDepth(depth);
-
- //IMPORTANT this is not going to be right for nested rows that
- //aren't visible, if someone expands/contracts we need to
- //re-assign the alternateRow status
-
- if (this._alternateRowClass){
- if (alternateRow){
- dojo.html.addClass(row.domNode,this._alternateRowClass);
- }
- else{
- dojo.html.removeClass(row.domNode,this._alternateRowClass);
- }
+ for (var i = 0; i<row._rows.length; i++){
+ this._rebuildRow(row._rows[i], depth+1);
+ }
+ },
+
+ //note this is kind of crappy as we recolor the entire table
+ //even if we expanded only the very last row. If we add/remove/expand/contract
+ //a row we only really need to start recoloring at that node
+ //TODO efficiency
+ _recolorAlternateRows: function(){
+ if (!this._alternateRowClass) return;
+ var alternateRow = false;
+ for (var i =0; i<this._rows.length; i++){
+ alternateRow = this._recolorRow(this._rows[i],alternateRow);
}
+ },
+
+
+ _recolorRow: function( row, alternateRow ){
+ if (alternateRow){
+ dojo.html.addClass(row.domNode,this._alternateRowClass);
+ }
+ else{
+ dojo.html.removeClass(row.domNode,this._alternateRowClass);
+ }
+
alternateRow = !alternateRow;
+
+ if (!row._expanded) return alternateRow;
+
for (var i = 0; i<row._rows.length; i++){
- alternateRow = this._rebuildRow(row._rows[i], depth+1, alternateRow);
+ alternateRow = this._recolorRow(row._rows[i], alternateRow);
}
return alternateRow;
},
-
/*
* Support for dynamic sizing
*/
@@ -506,6 +521,7 @@
*/
onExpandRow : function(row, expanded){
+ this._recolorAlternateRows();
//event hook
},