I figured out my problem. By changing the query to: query = db.auth_user.id>0 query = query&db.auth_group.id==SOME_VALUE
I was able to get the WHERE clause into the grid AND still be able to access fields in both tables. Previously I was only specifying query=db.auth_group.id == VALUE, which worked, but I could only show fields from the auth_group table in the grid. Elementary to most on this group, I'm sure, but I am posting back just in case another novice like me has the same problem. On Saturday, May 9, 2015 at 9:26:56 PM UTC-5, A36_Marty wrote: > > A few novice questions while learning the SQLFORM.grid on a throw-away > app. My apologies for the basic questions > > *1) How to show all users (auth_user) and related group roles > (auth_group.role) only for certain auth_groups?* > > I can display *all* groups with the following code, but can't seem to > figure out how to get the WHERE clause to SQLFORM.grid. > > query = db.auth_user > > fields = db.auth_user.first_name, db.auth_group.role > > left = db.auth_user.on( > db.auth_user.id == > db.auth_membership.user_id).db.auth_membership.on( > db.auth_membership.group_id == db.auth_group.id) > > grid = SQLFORM.grid(query = query, left=left, fields=fields) > > My failed attempts to get the WHERE clause inserted: > > query = (db.auth_group.id == PARENT_GROUP_ID) #No auth_user fields shown > > query = (db.auth_user)&(db.auth_group.id == PARENT_GROUP_ID) #get query > not supported error by the grid > > > *2) How to custom-format a column based on field values?* > > In the above grid example, if an auth_group.role of "Parent" is returned, > how can show something like a check mark (or any like boolean yes/no flag) > and nothing for anything other auth_group.role values? > > > Thanks in advance. A little nudge getting me through some the syntax > learning curve is much appreciated. > > > -- 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.