How does SQLFORM.grid know which table to edit?

93 views
Skip to first unread message

Jim S

unread,
Jul 11, 2013, 10:02:09 AM7/11/13
to web...@googlegroups.com
I have a controller method with a SQLFORM.grid in it.

The following setup:


    query = db.pricingIngredient.pricingIngredientId > 0
    left = [db.productSite.on(db.pricingIngredient.productSiteId==db.productSite.productSiteId),
            db.site.on(db.productSite.siteId==db.site.siteId),
            db.product.on(db.productSite.productId==db.product.productId)]

    grid = SQLFORM.grid(query, left)

When I click on the edit button I want to edit the pricingIngredient table.  However, SQLFORM.grid is taking me to edit the product table.

Is there a way to override this and force it to edit the pricingIngredient table without coding my own custom edit button?

-Jim

Massimo Di Pierro

unread,
Jul 11, 2013, 1:08:30 PM7/11/13
to web...@googlegroups.com
grid can only edit one table. smartgrid can edit referenced tables but not join them.
Unfortunately we cannot support both because logically it would be too complex. You can create your own custom button.

Jim Steil

unread,
Jul 11, 2013, 1:47:42 PM7/11/13
to web...@googlegroups.com
Thanks for the reply Massimo.  I know grid can only edit one table and that is what I want.  I'm just wondering how it chooses which table it is editing if the left parameter is specified.  Also, in my example above, it should be

grid = SQLFORM.grid(query, left=left)

-Jim


--
 
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Yl-6-oYA9C4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Massimo Di Pierro

unread,
Jul 11, 2013, 2:04:18 PM7/11/13
to web...@googlegroups.com
Good point! It should be the first table mentioned in the query but, this could be customizable. Please open a ticket about this.

Jim Steil

unread,
Jul 11, 2013, 2:13:06 PM7/11/13
to web...@googlegroups.com
I'll make up a little test app, submit a ticket and add the app for testing.

Jim S

unread,
Jul 11, 2013, 3:16:49 PM7/11/13
to web...@googlegroups.com
Ticket 1581

To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Herman Redelinghuys

unread,
Aug 4, 2015, 11:24:05 AM8/4/15
to web2py-users
I am struggling with the same issue as Jim. I dont want to create custom edit forms and if possible use the builtin edit form. Is there an answer for this yet? Did the ticket get actioned?

Thanks
Herman



Jim S

unread,
Aug 4, 2015, 3:06:43 PM8/4/15
to web2py-users
You can use the field_id parameter to specify the primary key field from the table that you want to edit.

Let me know if you have further questions.

-Jim
Reply all
Reply to author
Forward
0 new messages