add Line# column to autogrid
authorJason Etheridge <jason@esilibrary.com>
Wed, 14 Mar 2012 06:52:49 +0000 (02:52 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 19 Mar 2012 14:06:01 +0000 (10:06 -0400)
hidden by default, but we need to make it show up in autogrid's column picker

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/css/skin/default.css
Open-ILS/web/js/dojo/openils/widget/AutoGrid.js

index 1973b49..2098329 100644 (file)
@@ -75,6 +75,10 @@ table { border-collapse: collapse; }
 .dijitTooltipTable td {padding: 3px;} /* custom class for handling dialog tables */
 /* ----------------------------------------------------------------- */
 
+.autoGridLineNumber {
+    background-color: -moz-dialog;
+    font-weight: bold;
+}
 
 .oils-fm-edit-pane { margin: 5px; }
 .oils-fm-edit-pane td { padding: 5px; }
index 921f977..ba789e1 100644 (file)
@@ -25,9 +25,22 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
             suppressEditFields : null,
             suppressFilterFields : null,
             hideSelector : false,
+            hideLineNumber : false,
             selectorWidth : '1.5',
+            lineNumberWidth : '1.5',
             showColumnPicker : false,
             columnPickerPrefix : null,
+            onStyleRow : function(row) {
+                // FIXME: this really feels kludgy (sensitive to how dojo constructs the HTML), and is
+                // probably not idiomatic dojo
+                if (!this.hideLineNumber) {
+                    if (this.hideSelector) {
+                        dojo.addClass(row.node.firstChild.firstChild.firstChild.childNodes[0],'autoGridLineNumber');
+                    } else {
+                        dojo.addClass(row.node.firstChild.firstChild.firstChild.childNodes[1],'autoGridLineNumber');
+                    }
+                }
+            },
             displayLimit : 15,
             displayOffset : 0,
             requiredFields : null,
@@ -156,6 +169,10 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
             canSort : function(rowIdx) {
                 if(rowIdx == 1 && !this.hideSelector)
                     return false;
+                if(this.hideSelector && rowIdx == 1 && !this.hideLineNumber)
+                    return false;
+                if(!this.hideSelector && rowIdx == 2 && !this.hideLineNumber)
+                    return false;
                 return true;
             },
 
@@ -189,6 +206,16 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
                     });
                 }
 
+                if(!this.hideLineNumber) {
+                    // insert the line number column
+                    pushEntry({
+                        field : '+lineno',
+                        get : function(rowIdx, item) { if(item) return 1 + rowIdx; },
+                        width : this.lineNumberWidth,
+                        name : '#',
+                        nonSelectable : false
+                    });
+                }
 
                 if(!this.fieldOrder) {
                     /* no order defined, start with any explicit grid fields */