Should be
links = {
'person':[lambda row:
A(T('Delete'),_href=URL("configure","delete",args=["delete", 'person',
row.id]))],
'product':[lambda row:
A(T('Delete'),_href=URL("configure","delete",args=["delete", product',
row.id]))],
'purchase':[lambda row:
A(T('Delete'),_href=URL("configure","delete",args=["delete", 'purchase',
row.id]))]
}
without "db.". Almost all arguments in smartgrid can be dictionaries like
{'tablename':value} as opposed to value.
On Friday, 1 November 2013 11:24:10 UTC-5, [email protected] wrote:
>
> Ok, first I tried to make a dictionary:
>
> links = {
> 'db.person':[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.person',
> row.id]))],
> 'db.product':[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.product',
> row.id]))],
> 'db.purchase':[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.purchase',
> row.id]))]
> }
>
> But I could not figure out the links=? argument for SQLFORM.smartgrid.
>
> I've been printing the request.args on each pages, so I tried to hardcode
> based on argument numbers:
>
> # request.args(3) == 'purchase.product_id'
> if not request.args(3) == None:
> links=[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.purchase',
> row.id]))]
> # request.args(1) == 'product.seller_id'
> elif not request.args(1) == None:
> links=[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.product',
> row.id]))]
> else:
> # request.args(0) == 'person'
> links=[lambda row:
> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'db.person',
> row.id]))]
> grid =
> SQLFORM.smartgrid(db.person,linked_tables=['product','purchase'],
> user_signature=False, deletable=False,
> csv=False, links=links)
>
> This works! And I get the necessary information to process the delete in
> the proper table
> after display/confirmation in configure/delete.
>
> However, this solution feels like I'm one step away from a real answer.
> Is there a better
> way to determine how to pass to links=?
>
> Thanks for all your help!
> Kris
>
>
> On Friday, November 1, 2013 8:26:40 AM UTC-6, Massimo Di Pierro wrote:
>>
>> links = {'tablename':[lambda row:
>> A(T('Delete'),_href=URL("configure","delete",args=["delete", 'tablename',
>> row.id]))]}
>>
>> You can have one item for each tablename,
>>
>> On Friday, 1 November 2013 09:02:06 UTC-5, [email protected] wrote:
>>>
>>> I have a smartgrid example with delete button removed and a links=links
>>> dictionary for delete:
>>>
>>> links=[lambda row:
>>> A(T('Delete'),_href=URL("configure","delete",args=["delete", db.person,
>>> row.id]))]
>>>
>>> For children in the smartgrid, the delete URL request args remains the
>>> parent table name (db.person in this example).
>>> Is there a way to form links= such that the children will have their
>>> table name attached to the URL
>>> (so I delete the child and not the parent)?
>>>
>>> I found a horrible way to do this by placing the tablename inside the
>>> db.py definition to pass to the delete URL
>>>
>>> links=[lambda row:
>>> A(T('Delete'),_href=URL("configure","delete",args=["delete", row.tablename,
>>> row.id]))]
>>>
>>> but this was just an exercise and prone to way to many problems...
>>>
>>
--
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/groups/opt_out.