incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r448079 - /incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
Date Wed, 20 Sep 2006 05:48:44 GMT
Author: jmargaris
Date: Tue Sep 19 22:48:43 2006
New Revision: 448079

URL: http://svn.apache.org/viewvc?view=rev&rev=448079
Log:
updating +/- sign correctly, proof-of-concept sorting

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=448079&r1=448078&r2=448079
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js Tue Sep 19 22:48:43 2006
@@ -163,6 +163,7 @@
 
 	
 	insertColumn: function(column, index){
+		column.setTable(this);
 		if (index&&index>=0){
 			this.columns.splice(index,0, column);
 		}
@@ -190,6 +191,16 @@
 			this._rowAdded(row._rows[i]);
 		}
 		this._revalidate();
+	},
+	
+	//TODO PLACEHOLDER TEST CODE
+	sortColumn: function(){
+		this.rows.reverse();
+		
+		//when we do this what we really need to do is adjust the header
+		//icon and then rebuild ONLY the body, we don't need to rebuild
+		//the header row because that should remain constant.
+		this._revalidate();
 	}
 	
 }
@@ -225,7 +236,18 @@
 	
 	setHeader: function( domNode ){
 		this._header = domNode;
-//		domNode.style.display = "inline";
+		dojo.event.connect(domNode, "onclick", this, "onSort");
+	},
+	
+	setTable: function(table){
+		this._table = table;
+	},
+	
+	onSort : function(){
+		alert("Sort a column!");
+		if (this._table){
+			this._table.sortColumn();
+		}
 	}
 });
 		
@@ -261,22 +283,48 @@
 	
 	addCell : function( cell ){
 		var td = document.createElement("td");
-		if (this.domNode.childNodes.length==0){
+		this.domNode.appendChild(td);
+		if (!this._indentSpan){
 			this._indentSpan = document.createElement("span");
 			td.appendChild(this._indentSpan);
+			this._indentSpan.innerHTML = " ";
+			dojo.event.connect(this._indentSpan, "onclick", this, "onExpand");
+			this._adjustImage();
 		}
-		this.domNode.appendChild(td);
 		td.appendChild(cell);
 		cell._td = td;
 	},
 	
+	//adjust the class for the image for this row
+	//TODO we want to allow people to set these by doing something like:
+	//setLeafImage(...), setOpenImage(...) etc? If so we need more than
+	//a class we need to dynamically set the image
+	_adjustImage : function(){
+		if (!this._indentSpan){
+			return;
+		}
+		
+		var newClass = "";
+		if (this._imageClass){
+			dojo.html.removeClass(this._indentSpan, this._imageClass);
+		}
+		if (this._rows.length==0){
+			newClass = "";
+		}
+		else if (this._expanded){
+			newClass = "ImgNodeExpanded";
+		}
+		else{
+			newClass = "ImgNodeCollapsed";
+		}
+		dojo.html.addClass(this._indentSpan, newClass);
+		this._imageClass=  newClass;
+	},
+	
 	setDepth : function( depth ){
 		this._depth = depth;
 		if (this._indentSpan){
-			dojo.html.addClass(this._indentSpan, "ImgNodeExpanded");
-			this._indentSpan.style.marginLeft = (depth*10)+"px";
-			this._indentSpan.innerHTML = " ";
-			dojo.event.connect(this._indentSpan, "onclick", this, "onExpand");
+			this._indentSpan.style.marginLeft = (depth*10)+"px";		
 		}
 	},
 	
@@ -285,6 +333,7 @@
 		for (var i = 0; i<this._rows.length; i++){
 			this._rows[i].setVisible(this._expanded);
 		}
+		this._adjustImage();
 	},
 	
 	//if we set to invis, set all children to invis as well
@@ -320,6 +369,11 @@
 		}
 		if (this._table){
 			this._table._rowAdded(row);
+		}
+		
+		//after inserting first child we need to adjust +/- icon
+		if (this._rows.length==1){
+			this._adjustImage();
 		}
 		//after inserting a row we need to add the row to the parent table
 		



Mime
View raw message