for field in fields:
    fields2.append(db[field])

On Sep 11, 2:09 pm, tvw <surftas...@gmail.com> wrote:
> wow - thanks - worked straight away -  was just missing the *
>
> I get a list of fields from the checkboxes in request.vars.fields in
> the form "mytable.myfield"
>
> then I do this
>
> for field in fields:
>     fields2.append(eval('db.' + field))
>
> to get references to the gluon sql field objects to pass to the select
>
> this works but is this the correct way to do this (I don't really like
> doing the eval) ?
>
> On Sep 11, 3:03 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > myfields = [db.myable.fieldname1, db.mytable.fieldsname2]
> > SQLTABLE(db(db.mytable.id>0).select(*myfields))
>
> > On Sep 11, 1:56 pm, tvw <surftas...@gmail.com> wrote:
>
> > > Hi,
> > >     I am displaying a database table as a table in a page using jQuery
> > > dataTables - this is great but I also want to be able to select the
> > > database fields which are shown. I've put checkboxes below the table
> > > so that I will get returned a list of the fields I want to display.
> > > The problem is I can't get the select to work on a list, i.e.
>
> > > SQLTABLE(db(db.mytable.id>0).select(myfields))
>
> > > what form should myfields be in ?
>
> > >  SQLTABLE(db(db.mytable.id>0).select(db.mytable.ALL))
>
> > > works fine, but myfields = [fieldname1, fieldsname2, ...] doesn't
>
> > > can anyone help ?- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to