[view] ability to define a column header through custom label_column_<colindex> method, useful for table view to customize a specific column without specifying others stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 09 May 2011 17:42:28 +0200
branchstable
changeset 7346 c6d8c3ce4a3e
parent 7345 b9eaad6e34c3
child 7351 ed66f236715d
[view] ability to define a column header through custom label_column_<colindex> method, useful for table view to customize a specific column without specifying others
view.py
--- a/view.py	Mon May 09 16:12:17 2011 +0200
+++ b/view.py	Mon May 09 17:42:28 2011 +0200
@@ -447,11 +447,14 @@
         rqlstdescr = self.cw_rset.syntax_tree().get_description(mainindex,
                                                                 translate)[0]
         labels = []
-        for colindex, label in enumerate(rqlstdescr):
-            # compute column header
-            if label == 'Any': # find a better label
-                label = ','.join(translate(et)
-                                 for et in self.cw_rset.column_types(colindex))
+        for colidx, label in enumerate(rqlstdescr):
+            try:
+                label = getattr(self, 'label_column_%s' % colidx)()
+            except AttributeError:
+                # compute column header
+                if label == 'Any': # find a better label
+                    label = ','.join(translate(et)
+                                     for et in self.cw_rset.column_types(colidx))
             labels.append(label)
         return labels