Hi, 

Working with the SQLFORM.smartgrid i found undocumented behaviour. 

If i use linked tables, the fields selection is required for the linked 
tables grid as well. This might need a tune up in the docs. As it is a grid 
and thus valid - it caught me by surprise. Reading "in the grid view" to 
mean "in the main grid view"... It's a great and noteworthy feature worth 
documentation. 

In that same order of thought: orderby gave me some fuzz on my project with 
the linked tables. As soon as the orderby is present, the ordering works 
perfectly in the main grid but i get an error and no results in the grids 
of the linked tables. ( The error is "Query Not Supported: no such column: 
tile.name" when i view a linked table ) Since one might want to have 
different ordering on different tables/grids it surely makes sense. With a 
table named 'tile' i found myself with the following line of code to have 
the ordering in the tile grid and an error free experience in the linked 
tables. 

    options.orderby = (db.tile.name|~db.tile.effdt) if request.args[-1] == 
'tile' else None

After which i've learnt there is an easier undocumented way: 

    options.orderby = {'tile':(db.tile.name|~db.tile.effdt)}

My question would be to ask for an update of the documentation and have 
this article for future reference if someone encounters the same error.


This comes from the website: 


   - fields is a list of fields to be fetched from the database. It is also 
   used to determine which fields to be shown in the grid view. However, it 
   doesn't control what is displayed in the separate form used to edit rows. 
   For that, use the readable and writable attribute of the database fields. 
   For example, in a editable grid, suppress updating of a field like this: 
   before creating the SQLFORM.grid, set
   - orderby is used as default ordering for the rows.


regards, 
Remco 

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