Grid column picker repairs collab/senator/simplified-hpl
authorBill Erickson <berick@esilibrary.com>
Mon, 23 Apr 2012 16:34:56 +0000 (12:34 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 23 Apr 2012 16:34:56 +0000 (12:34 -0400)
reloadStructure now only refreshes the column names (which was the
original purpose of inserting the reload into flattenergrid) instead of
refreshing the entire structure.  this prevents losing visibility
information that was collected from the user setting.

Removed some inline CSS (min-height) which was apparently doing nothing.

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

index d0c86db..1d32bbe 100644 (file)
@@ -58,17 +58,29 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
             };
         },
 
-        /** Loads the current grid structure and passes the 
-         *  structure back to the grid to force a UI refresh.
-         *  This is necessary if external forces alter the structure. 
+        /** Loads any grid column label changes, clears any 
+         * non-visible fields from the structure, and passes 
+         * the structure back to the grid to force a UI refresh.
          */
         reloadStructure : function() {
-            this.cells = this.structure[0].cells[0].slice();
+
+            // update our copy of the column labels
+            var _this = this;
+            dojo.forEach(
+                this.grid.structure[0].cells[0],
+                function(gcell) {
+                    var cell = _this.cells.filter(
+                        function(c) { return c.field == gcell.field }
+                    )[0];
+                    cell.name = gcell.name;
+                }
+            );
+
             this.pruneInvisibleFields();
-            this.structure = this.grid.structure;
             this.grid.setStructure(this.structure);
         },
 
+
         // determine the visible sorting from the 
         // view and update our list of cells to match
         refreshCells : function() {
@@ -115,7 +127,7 @@ if(!dojo._hasResource["openils.widget.GridColumnPicker"]) {
                 "<th width='23%'>Auto Width</th><th width='23%'>Sort Priority</th></tr></thead>" +
                 "<tbody />"});
 
-            var tDiv = dojo.create('div', {style : 'min-height: 400px;'});
+            var tDiv = dojo.create('div');
             tDiv.appendChild(table);
 
             var bDiv = dojo.create('div', {style : 'text-align:right; width:100%;',