On Friday, September 13, 2013 1:57:28 PM UTC-7, 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))))])
>

I'm going to guess the "1 given" arg is  "row", and you need to use 
"filter=row.id" over on the end of your URL().
See below.


> 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 body is 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]),
>>
>
like this this ^^^ (see above)  


>>                                     _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, .......) 
>>
>>
>>
Apologies if I've gotten this wrong.

/dps
 

-- 
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.

Reply via email to