This worked perfectly, thanks!
On Tuesday, 25 August 2015 09:00:48 UTC-4, Jim S wrote:
>
> Here is what I do to put custom buttons on my grid view in SQLFORM.grid
>
> In my Controller:
>
> if not request.args(0) in ['view']:
> details = False
> links = [lambda row: getProductionDisplayAnchor(row)]
>
>
> grid = SQLFORM.grid(query, fields=fields,
> orderby=orderby, left=left,
> create=create, details=details,
> editable=editable, deletable=deletable,
> csv=False, search_widget=workorderSearch,
> paginate=15, maxtextlength=45,
> links=links, formstyle=my_formstyle, ui=grid_ui)
>
>
> And then the getProductionDisplayAnchor function
>
> def getProductionDisplayAnchor(row):
> """
> build the anchor tags for the action buttons on the Production list
> page
> """
> anchor = ''
> try:
> workorderId = row['workorder']['workorderId']
> except:
> workorderId = 0
>
>
> if workorderId > 0:
> anchor = A(SPAN(_class='glyphicon glyphicon-pencil') + (
> ' Record Usage' if db.workorder(workorderId).completed == None
> else 'View Usage'),
> _href=URL('production', args=('view', 'workorder',
> workorderId),
> user_signature=True),
> _class='btn btn-default') or ''
>
>
> return anchor
>
>
> From the web2py 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.
>
> You can find everything out about the SQLFORM.grid here:
> http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM-grid
>
> -Jim
>
>
> On Tuesday, August 25, 2015 at 6:03:41 AM UTC-5, Thomas Sitter wrote:
>>
>> I have, but I run into one issue -- the link brings me to a list of
>> records, but this is a 1-to-1 relationship so it will always be unnecessary
>> to display the list.
>>
>> On Tuesday, 25 August 2015 02:26:14 UTC-4, Anthony wrote:
>>>
>>> Have you considered SQLFORM.smartgrid?
>>
>>
--
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.