Seems to me this is an inconsistency in the way how grid operates (which breaks it, as I show below, but, of course, most probably I am just missing something.)
The following code crashes: query = db.cart fields = [db.cart.id] links = [dict(header='View', body=lambda row: str(*row.cart.id*))] grid = SQLFORM.grid(query, editable=True, details=True, links=links, fields=fields) This is because row.cart is undefined in the links. Instead, the links should be made as such: links = [dict(header='View', body=lambda row: str(*row.id*))] Now this works. However, when I add more fields in the code, like this: fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, db.cart_ownership.status, db.cart.count] Now in the links I can't use "row.id". It must be "row.cart.id" This by itself would be fine, I could just use *row.id* or *row.card.id* accordingly, depending on the fields used (though I would like to control this structure), but I am having the following problem further on: The grid described by the code query = db.cart fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, db.cart_ownership.status, db.cart.count] links = [dict(header='View', body=lambda row: str(row.cart.id))] grid = SQLFORM.grid(query, editable=True, details=True, links=links, fields=fields) crashes when I try to view or edit a row of the grid. This is because the links takes row.cart.id in the grid itself, but expects row.id in edit- or view- actions (i.e. when editing or viewing a row). When viewing or editing a row, row.cart is undefined in the links, so row.cart.id crashes it (when "view" or "edit" buttons are clicked), while in the grid itself row.cart.id works just fine (and row.id would not work). What am I missing here? How do I control how this field should be expected in the links in the grid vs. in the view/edit a row of the grid? Here is still simplified but more complete code, in case I missed something important in a "shortcut" code above: query = db.cart fields = [db.cart.id, db.cart.description, db.cart_ownership.boss, db.cart_ownership.status, db.cart.count] links = [dict(header='View', body=lambda row: str(row.cart.id))] grid = SQLFORM.grid(query, editable=True, details=True, links=links, fields=fields, left = [db.cart_ownership.on(db.cart.id==db.cart_ownership.cart)], field_id=db.cart.id, ) -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/58611d49-3cd2-407c-97f4-b34c9f2223d3n%40googlegroups.com.