Thanks for sharing.

On 23 September 2013 03:03, tomt <[email protected]> wrote:

> I thought I'd post the solution I came up with.
>
> It turned out to be easier than I thought it would be.  Just read the page
> number from request.vars.page, and pass it in the redirect after the
> form.accepts.
>
>
> # I define the links in a subroutine.
> def markup_body(row):
>     page = request.vars.page
>     if page:
>         body = 
> A('edit',_href=URL('markup_edit',args=(row.id),vars=dict(page=page))
> )
>     else:
>         body = A('edit',_href=URL('markup_edit',args=(row.id)) )
>
>     return body
>
> def markupgrid():
>     query = (db.sta_markup.id>0)
>     table=db.sta_markup
>     db.sta_markup.modified_on.readable = True  # force the field to be
> viewed
>     db.sta_markup.modified_by.readable = True
>     fields=[db.sta_markup.formatted_text,
>             db.sta_markup.modified_on,
>             db.sta_markup.modified_by,]
>     grid = SQLFORM.grid(query=query,
>
> details=False,csv=False,editable=False,deletable=False,create=False,searchable=True,
>
> paginate=5,fields=fields,links=[dict(header='Link',body=markup_body
> )],links_placement='left',
>         )
>     return dict(grid=grid)
>
> def markup_edit():
>     id = request.args(0)
>     page = request.vars.page
>     info = db.sta_markup(id)
>     form = SQLFORM(db.sta_markup,info,deletable = True, showid=False)
>     if form.accepts(request.vars, session):
>         response.flash='Changes saved'
>         redirect(URL(f='markupgrid',vars=dict(page=page)))
>
>     return dict(form=form)
>
>
>
> On Wednesday, September 18, 2013 9:57:33 PM UTC-6, tomt wrote:
>>
>> Hi,
>>
>> I'm looking for suggestions or examples on how I can implement a custom
>> edit function for SQLFORM.grid that will remember the page it was called
>> from, and return to it once the editing is complete.
>>
>> I was able to call the custom edit function easily enough by using the
>> 'links' parameter
>> links=[dict(header='edit',**body=lambda row: A('edit',_href=URL('edit_**
>> markup',args=(row.id))) )]
>>
>> edit_markkup uses SQLFORM to edit the record, and this is working
>> correctly, but I don't know how to code the redirect to return to the same
>> page position in the grid that it was called from. (In other words, if the
>> record I wanted to edit was on the second page, once editing was done, the
>> second page would be displayed)
>>
>> After searching through this group I believe that I have to pass the page
>> number and the signature, but I haven't figured out how to do this.
>>
>> If this is possible, I'd really appreciate a simple example of how to do
>> it.  - Tom
>>
>>  --
> 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.
>



-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

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