GridColumPicker hides sort selection for non-sortable fields
authorBill Erickson <berick@esilibrary.com>
Thu, 29 Mar 2012 13:12:01 +0000 (09:12 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 29 Mar 2012 13:12:01 +0000 (09:12 -0400)
Query the grid to determine when a column is sortable.  When not, simply
hide the sort priority selector.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/dojo/openils/widget/GridColumnPicker.js

index add99ad..fe22694 100644 (file)
@@ -165,7 +165,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                 ipt2.setAttribute('type', 'checkbox');
                 ipt2.setAttribute('name', 'width');
 
-                ipt3 = document.createElement('input');
+                ipt3 = document.createElement('div');
 
                 if (cell.nonSelectable) {
                     ipt.setAttribute('checked', 'checked');
@@ -196,14 +196,17 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                 else
                     this.dialogTable.appendChild(tr);
 
-                // this must be added after its parent node is inserted into the DOM.
-                var ns = new dijit.form.NumberSpinner(
-                    {   constraints : {places : 0}, 
-                        value : cell._sort || 0,
-                        style : 'width:4em',
-                        name : 'sort'
-                    }, ipt3
-                );
+                if ( this.grid.canSort(i+1) ) { // column index is 1-based
+
+                    // must be added after its parent node is inserted into the DOM.
+                    var ns = new dijit.form.NumberSpinner(
+                        {   constraints : {places : 0}, 
+                            value : cell._sort || 0,
+                            style : 'width:4em',
+                            name : 'sort',
+                        }, ipt3
+                    );
+                }
             }
         },
 
@@ -221,7 +224,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                 var sort = dojo.query('[name=sort]', row)[0];
                 var cell = this.cells[i]; // index should match dialog
 
-                if (cell._sort != sort.value) {
+                if (sort && cell._sort != sort.value) {
                     sortUpdated = true;
                     cell._sort = sort.value;
                 }