Thanks that's exactly what I was looking for! On Tuesday, 24 November 2015 14:44:18 UTC-5, Jim S wrote: > > You can use the field_id parameter on the SQLFORM.grid call to specify the > primary key field from the table that you want to be primary. > > > http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid-and-SQLFORM-smartgrid > > -Jim > > > On Tuesday, November 24, 2015 at 12:30:35 PM UTC-6, Thomas Sitter wrote: >> >> Hello, >> >> I have two tables that I'd like to join in a SQLFORM.grid. When viewing >> or editing an entry in the grid I'd like to edit the cheque table, but by >> default the customer table is selected. How can I change this? I've >> recreated the relevant code below. >> >> #db.py >> >> db.define_table('customer', >> Field('firstname', label = "First Name"), >> Field('lastname', label = "Last Name"), >> ) >> >> >> db.define_table('cheque', >> Field('customer_id', 'reference customer'), >> Field('cheque_sent', 'boolean'), >> Field('cheque_value', 'double'), >> ) >> >> >> #default.py >> >> def test_view(): >> query = ( >> (db.cheque.customer_id == db.customer.id) & >> (db.cheque.cheque_sent == True) >> ) >> >> fields = [ >> db.customer.lastname, >> db.cheque.cheque_sent, >> ] >> >> cheques = SQLFORM.grid(query=query, fields=fields) >> >> return dict(cheques=cheques) >> >> >> How do I change the behaviour of the grid to bring up a form for the >> cheques table rather than customer? >> >>
-- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

