Reporter: Sort contents of remote selector widgets
authorThomas Berezansky <tsbere@mvlc.org>
Wed, 3 Oct 2012 19:25:53 +0000 (15:25 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 28 Feb 2013 14:29:47 +0000 (09:29 -0500)
Simple sort based on the display value.

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/web/reports/oils_rpt_widget.js

index 7e644ec..28123d2 100644 (file)
@@ -523,6 +523,14 @@ oilsRptRemoteWidget.prototype.draw = function() {
 }
 
 oilsRptRemoteWidget.prototype.render = function(objs) {
+       var selector = this.field.selector;
+       objs.sort(
+               function(a,b){
+                       if (a[selector]() > b[selector]())
+                               return 1;
+                       else
+                               return -1;
+               });
        for( var i = 0; i < objs.length; i++ ) {
                var obj = objs[i];
                var label = obj[this.field.selector]();