sqlform.grid exporting with_hidden_cols

57 views
Skip to first unread message

Vincent

unread,
Jan 16, 2013, 12:42:32 PM1/16/13
to
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 in tablenames]
+                expfields = reduce(lambda a, b: a + b,
+                                [[field for field in table] for table in tables])
+                expcolumns = [f for f in expfields if f._tablename in tablenames]
             
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

Massimo Di Pierro

unread,
Jan 16, 2013, 10:46:20 PM1/16/13
to web...@googlegroups.com
Please open a googlecode thicket pointing here. We will review and probably accept it.

Vincent

unread,
Jan 18, 2013, 9:17:14 PM1/18/13
to web...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages