Never mind. I figured it out. Here's what I've got as a proof of concept: selected_fields=() fields = db.items.fields() for field in fields: selected_fields += db.items[field],
This gives the same output as if I manually entered selected_fields=(field_1,field_2,..field_n) On Monday, April 29, 2013 9:42:14 AM UTC-4, David S wrote: > > I've got a very nice looking grid from SQLFORM.grid based on my db.items, > however it has ~30 columns which can be too much information for the user. > I'd like to make it so the fields shown are selectable by the user. So far > I've created db.search which stores the user's search history and added > some Boolean fields to function as check boxes to hide/show the fields on > the SQLFORM used to search the db. The basic logic I'd like to use looks > like this: > > selected_fields = ? #empty field type? > > if(field_1_box_checked) > selected_fields += field_1 > if(field_2_box_checked) > selected_fields += field_2 > ... > if(field_n_box_checked) > selected_fields += field_n > > return dict(items=SQLFORM.grid(query,selected_fields)) > > Should field objects be combined using '+','&', or 'and'? I also read > here<https://groups.google.com/forum/?fromgroups=#!searchin/web2py/add$20fields/web2py/Wxor15Jwo2g/bqaRNNCceLIJ>it's > easy to generate a list of fields and use .remove("<field name>") to > remove an item from the list, but that's a list and not a field type. What > is the best way to do this? > > Thanks, > David > -- --- 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/groups/opt_out.