LP1211506 fix numeric sorting in staff client grids
authorBill Erickson <berick@esilibrary.com>
Tue, 13 Aug 2013 14:03:10 +0000 (10:03 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 14 Aug 2013 01:57:20 +0000 (21:57 -0400)
To recover numeric (vs. ascii-betical) sorting of number and money
values in grids, cast the cached sort values back into numbers.

This was tested in the billing interface, but should repair numeric
sorting for most grids.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/chrome/content/util/list.js

index 1ddfb0f..d4e5039 100644 (file)
@@ -1784,6 +1784,14 @@ util.list.prototype = {
                                 if (a.sort_value) {
                                     a = a.sort_value;
                                     b = b.sort_value;
+
+                                    // ensure that numeric values have not
+                                    // morphed into strings along the way.
+                                    if (obj.columns[p].sort_type == 'money' ||
+                                        obj.columns[p].sort_type == 'number') {
+                                        a = Number(a);
+                                        b = Number(b);
+                                    }
                                 } else {
                                     a = a.value;
                                     b = b.value;