fixed grid export with custom search, thanks Prasad Muley

This commit is contained in:
mdipierro
2015-01-15 09:58:13 -06:00
parent bda69b0e88
commit c6cc06f6c0
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.9.12-beta+timestamp.2015.01.15.09.47.52
Version 2.9.12-beta+timestamp.2015.01.15.09.58.09
+14 -1
View File
@@ -2326,7 +2326,7 @@ class SQLFORM(FORM):
expcolumns.append(str(field))
if export_type in exportManager and exportManager[export_type]:
if keywords:
if keywords and not callable(searchable):
try:
#the query should be constructed using searchable
#fields but not virtual fields
@@ -2339,6 +2339,19 @@ class SQLFORM(FORM):
except Exception, e:
response.flash = T('Internal Error')
rows = []
elif callable(searchable):
#use custom_query using searchable
try:
#the query should be constructed using searchable
#fields but not virtual fields
sfields = reduce(lambda a, b: a + b,
[[f for f in t if f.readable and not isinstance(f, Field.Virtual)] for t in tables])
dbset = dbset(searchable(sfields, keywords))
rows = dbset.select(left=left, orderby=orderby,
cacheable=True, *selectable_columns)
except Exception, e:
response.flash = T('Internal Error')
rows = []
else:
rows = dbset.select(left=left, orderby=orderby,
cacheable=True, *selectable_columns)