I am trying to export a grid with a custom exporter that has a name ending 
"with_hidden_cols" in order to export a complete table (and more).

However, my exported file does not contain the hidden cols.

I have diagnosed the problem and believe the following changes yields the 
expected behavior:
--- a/gluon/sqlhtml.py
+++ b/gluon/sqlhtml.py
@@ -2016,7 +2016,9 @@ class SQLFORM(FORM):
 
             expcolumns = columns
             if export_type.endswith('with_hidden_cols'):
-                expcolumns = [f for f in fields if f._tablename intablenames
]
+                expfields = reduce(lambda a, b: a + b,
+                                [[field for field in table] for table intables
])
+                expcolumns = [f for f in expfields if f._tablename intablenames
]
             if export_type in exportManager and exportManager[export_type]:
                 if request.vars.keywords:
                     try:

I specify "fields" when creating the grid because I want to limit the 
number of visible columns. However, in the original sqlhtml.py code the 
"expcolumns" variable is set using the "fields" variable that has already 
been limited to the visible columns. My change simply defines a new 
variable "expfields" using the original way "fields" is defined when it is 
not specified on grid creation.

I believe this now has the expected behavior. I am using web2py from trunk.

Thanks
Vincent

-- 



Reply via email to