It takes a bit of coding. Something like this:
db.define_table('mytable',Field('name'))
def select():
session.records=[]
db.mytable.id.represent=lambda v: \
INPUT(_type='checkbox',
_id='r%s' % v,
_name='%s' % v,
_onclick="ajax('{{=URL(r=request,f='select_callback',args=v)}}'\,
[],':eval')")
rows=db(db.mytable.id>0).select()
return
(rows=SQLTABLE(rows),link=A('csv',_href=URL(r=request,f='download_csv')))
def select_callback():
id = int(request.args(0))
if id in session.records=[]:
session.records=[i for i in session.records if not i==id]
return "jQuery('#r%s').attr('checked',false)" %
request.args(0)
else:
session.records.append(id)
return "jQuery('#r%s').attr('checked',true)" % request.args(0)
def csv():
import StringIO
s=StringIO.StringIO()
db(db.mytable.id.belongs(session.records)).select().export_to_csv_field(s)
return s.getvalue()
On Mar 22, 8:15 am, Johann Spies <[email protected]> wrote:
> My client wants to be able to select from a list of records (SQLTABLE)
> which records to output in a csv-file (or pdf).
> Is this possible to do that using SQLTABLE?
>
> Regards
> Johann
>
> --
> "Blessed are the poor in spirit: for theirs is the
> kingdom of heaven...Blessed are they which do hunger
> and thirst after righteousness: for they shall be
> filled...Blessed are the pure in heart: for they shall
> see God." Matthew 5:3,6,8
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.