AutoGrid line number CSS application cleanup
authorBill Erickson <berick@esilibrary.com>
Thu, 15 Mar 2012 17:54:02 +0000 (13:54 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 19 Mar 2012 14:06:06 +0000 (10:06 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/dojo/openils/widget/AutoGrid.js

index ba789e1..0faa3ee 100644 (file)
@@ -30,17 +30,6 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
             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,
@@ -51,6 +40,14 @@ if(!dojo._hasResource['openils.widget.AutoGrid']) {
             /* by default, don't show auto-generated (sequence) fields */
             showSequenceFields : false, 
 
+            // style the cells in the line number column
+            onStyleRow : function(row) {
+                if (!this.hideLineNumber) {
+                    var cellIdx = this.hideSelector ? 0 : 1;
+                    dojo.addClass(this.views.views[0].getCellNode(row.index, cellIdx), 'autoGridLineNumber');
+                }
+            },
+
             startup : function() {
                 this.selectionMode = 'single';
                 this.sequence = openils.widget.AutoGrid.sequence++;