Do you know how to use web2py's DAL to make a query which joins tables? http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Inner-joins
Once you do, give that query to SQLFORM.grid Note that you need to understand what exactly a DAL "query" is. The term is subtly different from what you may expect if you are thinking of SQL queries. A DAL query on its own does not return rows: a DAL query defines what is to be selected (such as what the join is) but on its own is simply an expression, not a set of data. I found this a little confusing at the beginning: 'query' is a DAL formal term which does not by itself include returned data. The DAL uses the term "set" when the query is put in the context of a database. http://www.web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Query--Set--Rows The grid needs only a DAL query, not a set of rows. http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid "The first argument of SQLFORM.grid can be a table or a query. The grid object will provide access to records matching the query." On Sunday, 4 January 2015 06:12:41 UTC+11, Roman Rakus wrote: > > Hi, I have folloving tables. > db.define_table('tbl1', Field('code', 'string')) > db.define_table('tbl2', Field('field1', 'integer', 'reference tbl1'), > Field('field2', 'integer', 'reference tbl1')) > > Now I need render values from tbl2 in sqlform.grid. How I can join > tbl2.field1 and tbl2.field2 on tbl1? > -- 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.