Hi Matt,

I'm no expert (only discovered the wonders of the grid in the last couple 
of weeks) and maybe others 
will have a better way but I have tested this and it might get you going...

(Also you might want to give a little more information on the 
requirements... 
Where have you got to? 
Do the reports require further interaction/parameters when selected? 
Have you developed the reports themselves?)  

# So as far as I understand it, the grid requires a table (or possibly a 
dummy table? I went with a real one)

db.define_table('reports',
                Field('report_name',),
                Field('report_function',)
                )

and added two records...
    1, Activities Report, csv_activities
    2, Companies Report, csv_companies


The report_functions should point to valid report functions/views 
that you have created (I can provide some info on this if needed)


def output_reports():
    print "output reports: received vars %s" % request.vars
    for record_id in request.vars.id:
        print "run report %s" % db.reports[record_id].report_function
    redirect(URL('report_factory',[]))
    

def report_factory():
    query = db.reports.id > 0
    fields = (db.reports.id, db.reports.report_name)
    grid = SQLFORM.grid(query,
                        field_id= db.reports.id,
                        fields=fields,
                        searchable=False,
                        create=False,
                        selectable=lambda ids: redirect(URL('default', 
'output_reports', vars=dict(id=ids))),
                        editable=False,
                        deletable=False,
                        details=False,
                        buttons_placement='right',
                        csv=False
                        )

    return dict(grid=grid)



The print output below shows what is happening and simulates 'running 
report/s'  
after selecting each report separately and then the two together


output reports: received vars <Storage {'id': '1'}>
run report csv_activities

output reports: received vars <Storage {'id': '2'}>
run report csv_companies

output reports: received vars <Storage {'id': ['1', '2']}>
run report csv_activities
run report csv_companies


Hope this helps!
Peter

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to