--- trac-0.12dev-integration/trac/ticket/report.py	2010-02-21 12:25:43.000000000 +0100
+++ ReportPatch/trac/ticket/report.py	2010-03-13 00:18:50.000000000 +0100
@@ -436,6 +436,22 @@
                 header_groups.append([])
             header_group.append(header)
 
+        maxcols = 0 
+        for header_group in header_groups:
+            numhidden = 0
+            numcols = 0
+            for header in header_group:
+                if header['hidden']:
+                    numhidden += 1
+                else:
+                    numcols += 1
+            maxcols = numcols > maxcols and numcols or maxcols
+	    i = 1
+            for header in header_group:
+                header['numhidden'] = numhidden
+                header['grpindex'] = i
+                i += 1
+
         # Structure the rows and cells:
         #  - group rows according to __group__ value, if defined
         #  - group cells the same way headers are grouped
@@ -467,10 +483,10 @@
                                '__fgcolor__', '__bgcolor__',
                                '__grouplink__'):
                         row[col] = value
-                    if col in ('report', 'ticket', 'id', '_id'):
+                    col = col.strip('_')
+                    if col in ('report', 'ticket', 'id'):
                         row['id'] = value
                     # Special casing based on column name
-                    col = col.strip('_')
                     if col in ('reporter', 'cc', 'owner'):
                         email_cells.append(cell)
                     elif col == 'realm':
@@ -505,6 +521,7 @@
         data.update({'header_groups': header_groups,
                      'row_groups': row_groups,
                      'numrows': numrows,
+                     'maxcols': maxcols,
                      'sorting_enabled': len(row_groups)==1,
                      'email_map': email_map})
 
@@ -765,3 +782,4 @@
         report, args, fragment = formatter.split_link(target)
         return tag.a(label, href=formatter.href.report(report) + args,
                      class_='report')
+

