Revision: 3353
          http://vexi.svn.sourceforge.net/vexi/?rev=3353&view=rev
Author:   clrg
Date:     2009-01-13 20:38:01 +0000 (Tue, 13 Jan 2009)

Log Message:
-----------
Make table body more robust (i.e. not break on null cell contents)

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t       
2009-01-13 12:40:20 UTC (rev 3352)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/body.t       
2009-01-13 20:38:01 UTC (rev 3353)
@@ -108,7 +108,7 @@
         }
         
         /** compares two strings */
-        var compString = function(a, b) { return a.toLowerCase() > 
b.toLowerCase(); }
+        var compString = function(a, b) { return (a?a.toLowerCase():null) > 
(b?b.toLowerCase():null); }
         
         /** compares two numbers */
         var compNumber = function(a, b) { return a > b; }
@@ -118,7 +118,8 @@
             var lo, mid, hi;
             var n = numchildren;
             // robustly select comparison function
-            var comp = (datatype == "number") ? compNumber : compString;
+            var comp = (datatype == "string") ? compString : compNumber;
+            if (vexi.debug) vexi.log.info("sorting: "+ind+", "+datatype+", 
"+n);
             // iterate through children
             for (var i=1; n > i; i++) {
                 // [v0, ..., v[i-1], v[i] - keep current order
@@ -165,9 +166,10 @@
         thisbox.sortDescending = function(ind, datatype) {
             var lo, mid, hi;
             var n = numchildren;
-            var comp = (datatype == "number") ? compNumber : compString;
+            var comp = (datatype == "string") ? compString : compNumber;
+            if (vexi.debug) vexi.log.info("sorting: "+ind+", "+datatype+", 
"+n);
             // iterate through children
-            for (var i=1; n > i; i++) {
+            for (var i=1; n>i; i++) {
                 // [v0, ..., v[i-1], v[i] - keep current order
                 if (comp(thisbox[i-1][ind].value, thisbox[i][ind].value))
                     continue;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to