incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r473620 - /incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js
Date Sat, 11 Nov 2006 01:43:55 GMT
Author: jmargaris
Date: Fri Nov 10 17:43:54 2006
New Revision: 473620

URL: http://svn.apache.org/viewvc?view=rev&rev=473620
Log:
More work on tree sort

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=473620&r1=473619&r2=473620
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/TreeTable.js Fri Nov 10 17:43:54 2006
@@ -494,13 +494,26 @@
 			var cellInfo = row._cellInfo[index];
 			var sortValue = cellInfo._sortValue || cellInfo._text;
 			
-			//value to sort by
-			row._sortValue = sortValue;
+			if (dataType=='number'){
+				//value to sort by
+				row._sortValue = parseFloat(sortValue);
+			}
+			else if (dataType=='integer'){
+				row._sortValue = parseInt(sortValue);
+			}
+			else{
+				row._sortValue = sortValue;
+			}
 		}
 		
+		var sortFunction = this._sortStringsFunction;
+		
+		if (dataType=="number"){
+			sortFunction = this._sortNumbersFunction;
+		}
 		//sort the array and change _rows to match
 		//TODO choose different functions based on data types!
-		this._rows.sort(this._sortStringsFunction);
+		this._rows.sort(sortFunction);
 		
 		
 		
@@ -525,11 +538,16 @@
 	_sortStringsFunction: function(a, b){
 		var aVal = a._sortValue.toLowerCase();
 		var bVal = b._sortValue.toLowerCase();
-		if (aVal==b.val) return 0;
+		if (aVal==bVal) return 0;
 		if (aVal<bVal) return -1;
 		return 1;
-	}
+	},
 	
+	_sortNumbersFunction: function(a, b){
+		if (aVal==bVal) return 0;
+		if (aVal<bVal) return -1;
+		return 1;
+	}
 }
 );
 



Mime
View raw message