I managed to solve the issue with the following code
def csvExport():
scriptId = request.args[0]
#rows = db(query,ignore_common_filters=True).select()
rows = db(db.result.r_id_script == scriptId).select(db.result.r_item1_name,
db.result.r_date, db.result.r_time_start,db.result.r_time_end)
from gluon.contenttype import contenttype
response.headers['Content-Type'] = contenttype('.csv')
response.headers['Content-disposition'] = 'attachment;
filename=export_%s.csv' % (scriptId)
import csv, cStringIO
s = cStringIO.StringIO()
rows.export_to_csv_file(s, delimiter=',', quotechar='"',
quoting=csv.QUOTE_NONNUMERIC)
return s.getvalue()
andbutton in my view.html
{{=A(T('CSV export'), _class='btn btn-primary',
_href=URL('script','csvExport', args = request.args[0]))}}
instead of callback i used _href
it works :)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.