Here is a sample we have where we add 'links'.
links = [lambda row: A(XML('<span class="glyphicon glyphicon-pencil
space-after"></span> Edit'),
_href=URL('sample', 'sample', vars={'sample_id':
row.sample.id}, user_signature=True),
_class='btn btn-default'),
lambda row: A(XML('<span class="glyphicon glyphicon-pencil
space-after"></span> Reports'),
_href=URL('sample', 'sample_reports', vars={'sample_id':
row.sample.id},
user_signature=True), _class='btn
btn-default'),
lambda row: A(XML('<span class="glyphicon glyphicon-paperclip
space-after"></span> Attach Document'),
_href=URL('sample', 'sample_attach_document',
vars={'sample_id': row.sample.id},
user_signature=True), _class='btn
btn-default', _name='attach_document'),
lambda row: A(XML('<span class="glyphicon glyphicon-eye-open
space-after"></span> View Attached'),
_onclick='open_modal(%s)' % row.sample.id, _class='btn
btn-default') if row.sample_attachment.id else None
]
It appears to me that your first 'link' is actually an extra column that
you're adding to your grid.
Then, the second dict shouldn't be a dict at all, links should just be a
list of your lambdas, like you have in the 'body' of the second dict.
-Jim
On Friday, June 15, 2018 at 11:57:54 AM UTC-5, watr wrote:
>
> Here is my links code:
>
> links = [
> dict(header='Balance', body=lambda row: row.po.amount -
> row.invoice_items.amount_pretax),
> dict(header='Controls', body=[
> lambda row: A('Invoices',_class='button btn
> btn-default',_href=URL('invoice', 'list', args=['commitment', row.po.id],
> vars=dict(source=here))),
> lambda row: A('Edit',_class='button btn
> btn-default',_href=URL('edit', args=row.po.id, vars=dict(source=here))),
> lambda row: A('Files',_class='button btn
> btn-default',_href=URL('attachments', 'list', args=['commitment',row.po.id],
> vars=dict(source=here))),
> lambda row: A('Delete',_class='button btn
> btn-default',_href=URL('delete', args=row.po.id, vars=dict(source=here)))
> ]
> ]
>
> However, I get an "attribution error" for the first dict, and a "list not
> callable" for the controls dict.
>
> What is the correct method for adding multiple columns with one column
> having multiple links in it?
>
--
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.