It's in the book 
<http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-signature>
 
(hint, it's the second argument).

On Saturday, July 9, 2016 at 4:57:12 AM UTC-4, Alex Glaros wrote:
>
> can someone please remind me of syntax for limiting fields in query for 
> grid?
>
> Below correctly works to create SQL query, not data
>
> query = db((db.strategic_goal.transparency_level_fk == 1) & 
> (db.strategic_goal.organization_fk == 
> db.Organization.id))._select(db.strategic_goal.strategic_goal_title, 
> db.strategic_goal.strategic_goal_description, 
> db.strategic_goal.transparency_level_fk, 
> db.strategic_goal.comments_enabled, 
> db.strategic_goal.strategic_goal_comments, 
> db.Organization.organization_full_name, db.strategic_goal.organization_fk) 
>
> but when I put it in grid command,
>     
> grid = SQLFORM.grid(query)
>
> I get
>
> <type 'exceptions.AttributeError'> 'str' object has no attribute '_db'
>
>   File "C:/alex/alt_web2py_4/web2py/applications/ES3/controllers/default.py" 
> <http://127.0.0.1:8000/admin/default/edit/ES3/controllers/default.py>, line 
> 7486, in view_all_strategic_goals
>     grid = SQLFORM.grid(query, create = False, editable = False, deletable = 
> False, maxtextlength = 140, maxtextlengths = 
> {'strategic_goal.transparency_level_fk':18, 
> 'strategic_goal.comments_enabled':23}, 
> fields=[db.strategic_goal.strategic_goal_title, 
> db.strategic_goal.strategic_goal_description, 
> db.strategic_goal.transparency_level_fk, db.strategic_goal.comments_enabled, 
> db.strategic_goal.strategic_goal_comments, 
> db.Organization.organization_full_name, db.strategic_goal.organization_fk])  
> ### fix this: need an "onupdate" for when title changes.
>   File "C:\alex\alt_web2py_4\web2py\gluon\sqlhtml.py", line 2090, in grid
>     db = query._db
> AttributeError: 'str' object has no attribute '_db'
>
>
>       raise RuntimeError('SQLFORM.grid ui argument must be a dictionary')
>
>         db = query._db
>
> thanks
>
> Alex Glaros
>
>
>

-- 
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