[table view] allow to set None in 'headers', meaning the label should be fetched from the result set as done by default (closes #1931533)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 16 Sep 2011 12:48:28 +0200
changeset 7801 67f9677c1253
parent 7800 ea496a3ed703
child 7802 d0bf71aff4a1
[table view] allow to set None in 'headers', meaning the label should be fetched from the result set as done by default (closes #1931533) the point of this is to avoid having to define the whole headers list when only some of them have to be defined.
web/views/tableview.py
--- a/web/views/tableview.py	Fri Sep 16 12:48:26 2011 +0200
+++ b/web/views/tableview.py	Fri Sep 16 12:48:28 2011 +0200
@@ -192,7 +192,9 @@
                 continue
             # compute column header
             if headers is not None:
-                label = headers[displaycols.index(colindex)]
+                _label = headers[displaycols.index(colindex)]
+                if _label is not None:
+                    label = _label
             if colindex == mainindex and label is not None:
                 label += ' (%s)' % self.cw_rset.rowcount
             column = TableColumn(label, colindex)