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_suggestion', 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) & 
>>>>>>> (db.IdeaComment.partyID==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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to