Have to use redirect(URL(..), client_side=True)

domingo, 10 de Março de 2019 às 14:20:39 UTC, João Matos escreveu:
>
> Hello,
>
> I'm unable to redirect to another page from a grid's ondelete.
> I have this grid in the index function of a controller
>
>         grid: DIV = SQLFORM.grid(
>             db.client, csv=False, details=False,
>             # noconfirm=True,  # Grid only.
>             ondelete=on_delete,  # Grid only.
>             onvalidation=on_validation,  # Form only.
>             orderby=db.client.name,
>             paginate=session.auth.user.pagination,
>             # represent_none='',  # Grid/view form only.
>             searchable=False,
>         )
>
> and the on_delete function is this
>
> @auth.requires(lambda: (auth.is_logged_in() and request.env.http_referer
>                         and '/client' in request.env.http_referer))
> def on_delete(table, rec_id):
>     # type: (pydal.objects.Table, str) -> None
>     """Grid delete button action (does not redirect to other pages).
>
>     :param table: Table.
>     :param rec_id. Record id.
>     """
>     row: pydal.objects.Row = table(rec_id)
>     row.update_record(cancel_approved_by=auth.user_id, 
> canceled_by=auth.user_id,
>                                canceled_on=request.now, is_active=False)
>     session.flash = T('Press F5 to refresh.')
>     redirect(URL(user_signature=True))
>
> That works.
>
> However, if I change the redirection to another page, eg.
>
>
>     redirect(URL('diff_page', user_signature=True))
>
> or even another page in a different controller
>
>     redirect(URL('default', 'index', user_signature=True))
>
> the redirection doesn't work and there is no error.
>
> Is this behaviour correct?
>
> If I do the same in the grid's onvalidation, the redirection works.
>
> Thanks,
>
> JM
>

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

Reply via email to