You need pass a list of dict
links = [{'header':'', 'body': lambda row:
A('',_title='Procesar',_class='icon-refresh',_href=URL(c='planilla',
{'header':'', 'body': lambda row:
A('',_title='Mail',_class='icon-envelope',_href='index/pedircontadores/%
{'header':'', 'body': lambda row:
A('',_title='Estado',_class='icon-ok',callback=URL(c='planilla',f='estad
{'header':'', 'body': lambda row:
A('',_title='Control',_class='icon-check',_href=URL(c='planilla',f='pdf/
{'header':'', 'body': lambda row: A('',_title='Control
2',_class='icon-check',_href=URL(c='planilla',f='co
{'header':'', 'body': lambda row:
A('',_title='PDF',_class='icon-print',_href=URL(f='pdf/%s/%s' % (row.id,
{'header':'', 'body': lambda row: A('',_title='PDF
distribuidor',_class='icon-print',_href=URL(f='pdf/%s/%
{'header':'', 'body': lambda row:
A('',_title='Detalle',_class='icon-list',_href=URL(c='detalle',f='index'
]
On Sun, Sep 15, 2013 at 9:31 PM, Alex Glaros <[email protected]> wrote:
> What is syntax for TWO or more buttons? I've tried several variations.
> Would it be two "dict" phrases, or two header phrases separated by commas?
>
> One button will call one function, and the other would call a different
> function.
>
> thanks,
>
> Alex
>
>
> On Saturday, September 14, 2013 6:56:24 PM UTC-7, Alex Glaros wrote:
>>
>> Works perfect Adi and Villas,
>>
>> much appreciated.
>>
>> Here's the complete code:
>>
>> def view_all_suggestions_and_**comments():
>> query = (db.IdeaComment.ideaID==db.**Idea.id <http://db.Idea.id>) &
>> (db.IdeaComment.partyID==db.**Party.id <http://db.Party.id>)
>> grid = SQLFORM.grid(query, ,links = [dict(header='Virtual Field',
>> body=lambda row: A('Add a comment!',_class="btn btn-mini",
>> _href=URL('comment_on_a_**suggestion', vars=dict(filter=row.Idea.id))**
>> ))])
>> return dict(grid = grid)
>>
>> Alex
>>
>>
>> On Saturday, September 14, 2013 6:01:33 PM UTC-7, Adi wrote:
>>>
>>> lambda row: A('Complete',
>>> _class='btn', _id='btn_complete',
>>> _onclick='return confirm("Complete
>>> Order %s? (%s %s)")' % (row.id,
>>>
>>> row.shipFirstName,
>>>
>>> row.shipLastName),
>>> _href=URL(r=request,f='**
>>> complete_order',args=[row.id])**,
>>>
>>>
>>>
>>>
>>> On Saturday, September 14, 2013 7:41:24 PM UTC-4, Alex Glaros wrote:
>>>>
>>>> it works correctly Villas, thanks.
>>>>
>>>> how could I turn "Add a comment!" text into a button. Possible syntax
>>>> ",_class="btn btn-mini"", but where does it go?
>>>>
>>>> thanks,
>>>>
>>>> Alex
>>>>
>>>> On Saturday, September 14, 2013 10:23:00 AM UTC-7, villas wrote:
>>>>>
>>>>> Maybe this would work using row.idea.id like this...
>>>>>
>>>>> grid = SQLFORM.grid(query,
>>>>> links = [dict(header='Virtual Field',
>>>>> body=lambda row: A('Add a comment!', _href=URL('comment_on_a_**
>>>>> suggestion', vars=dict(filter=row.idea.id <http://row.id/>))**)
>>>>> )]
>>>>> )
>>>>>
>>>>>
>>>>> You can also now include "virtual fields" in grids, but I haven't
>>>>> needed to try that yet.
>>>>>
>>>>>
>>>>>
>>>>> On Saturday, 14 September 2013 15:23:49 UTC+1, Alex Glaros wrote:
>>>>>>
>>>>>> thanks Villas but I receive this error: Row' object has no attribute
>>>>>> 'id'
>>>>>>
>>>>>> perhaps it doesn't know which of the joined "id"s to reference
>>>>>>
>>>>>> this work-around works because it let's system know which id it is:
>>>>>> db.Idea.id.represent = lambda id, r: A('Add a comment!',
>>>>>> _href=URL('comment_on_a_sugges**tion', vars=dict(filter=id)))
>>>>>>
>>>>>> Alex
>>>>>>
>>>>>> On Saturday, September 14, 2013 4:56:33 AM UTC-7, villas wrote:
>>>>>>>
>>>>>>> Try this...
>>>>>>>
>>>>>>> grid = SQLFORM.grid(query,
>>>>>>> ** links = [dict(header='Virtual
>>>>>>> Field',
>>>>>>> ** body=lambda
>>>>>>> row: A('Add a comment!', _href=URL('comment_on_a_**suggestion',
>>>>>>> vars=dict(filter=row.id)))
>>>>>>> ** )]
>>>>>>> ** )
>>>>>>>
>>>>>>>
>>>>>>> On Friday, 13 September 2013 21:57:28 UTC+1, Alex Glaros wrote:
>>>>>>>>
>>>>>>>> I tried this but got "lambda requires 2 args, 1 given" error, plus
>>>>>>>> need to be able to pass Idea.id parm to the button. How to do that?
>>>>>>>>
>>>>>>>> grid = SQLFORM.grid(query,links = [dict(header='Virtual
>>>>>>>> Field',body=lambda id, r: A('Add a comment!', _href=URL('comment_on_a_
>>>>>>>> **suggestion', vars=dict(filter=id))))])
>>>>>>>>
>>>>>>>> On Friday, September 13, 2013 1:33:35 PM UTC-7, villas wrote:
>>>>>>>>>
>>>>>>>>> Hope this helps...
>>>>>>>>>
>>>>>>>>> From the book:
>>>>>>>>>
>>>>>>>>> links is used to display new columns which can be links to other
>>>>>>>>> pages. The links argument must be a list of
>>>>>>>>> dict(header='name',body=lambda
>>>>>>>>> row: A(...)) where header is the header of the new column and bodyis
>>>>>>>>> a function that takes a row and returns a value. In the example, the
>>>>>>>>> value is a A(...) helper.
>>>>>>>>>
>>>>>>>>> Example:
>>>>>>>>>
>>>>>>>>> linkbtns = [
>>>>>>>>> lambda row: SPAN('Mag',_class="label
>>>>>>>>> label-success") \
>>>>>>>>> if row.status =='Y' else '',
>>>>>>>>> lambda row: SPAN('Web',_class="label
>>>>>>>>> label-success") \
>>>>>>>>> if row.is_active else '',
>>>>>>>>> lambda row: A( I('',_class="icon-eye-open")+'
>>>>>>>>> View',
>>>>>>>>> _href=URL("view",args=[row.id]
>>>>>>>>> **),
>>>>>>>>> _class="btn btn-small"
>>>>>>>>> ),
>>>>>>>>> lambda row: A( I('',_class="icon-edit")+' Edit',
>>>>>>>>> _href=URL("edit",args=[row.id]
>>>>>>>>> **),
>>>>>>>>> _class="btn btn-small"
>>>>>>>>> ),
>>>>>>>>> lambda row: A( I('',_class="icon-road")+' Map',
>>>>>>>>> _href=URL('default','geocoder'
>>>>>>>>> **,args=['caclient',row.id],vars**={'title':row.business}),
>>>>>>>>> _class="btn btn-small"
>>>>>>>>> ),
>>>>>>>>> ]
>>>>>>>>> grid = SQLFORM.grid(....... links=linkbtns, .......)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Friday, 13 September 2013 21:00:56 UTC+1, Alex Glaros wrote:
>>>>>>>>>>
>>>>>>>>>> How do I add a button "Add a comment!" in every row of a grid?
>>>>>>>>>> It's a kind of virtual column.
>>>>>>>>>>
>>>>>>>>>> The below works, it takes user exactly to the correct row in the
>>>>>>>>>> next table, but I use up one of the fields (Idea.id). How do I just
>>>>>>>>>> create
>>>>>>>>>> text/virtual column that doesn't sacrifice existing field?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> def view_all_suggestions_and_**comments():
>>>>>>>>>> db.Idea.id.represent = lambda id, r: A('Add a comment!',
>>>>>>>>>> _href=URL('comment_on_a_**suggestion', vars=dict(filter=id)))
>>>>>>>>>> query = (db.IdeaComment.ideaID==db.**Idea.id<http://db.Idea.id>)
>>>>>>>>>> & (db.IdeaComment.partyID==db.**Party.id <http://db.Party.id>)
>>>>>>>>>> grid = SQLFORM.grid(query)
>>>>>>>>>> return dict(grid = grid)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I read the book but need exact syntax for this situation.
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>>
>>>>>>>>>> Alex Glaros
>>>>>>>>>>
>>>>>>>>> --
> 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.
>
--
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.