Ok, the solution I've gone with is to set editable=False in the SQLFORM
constructor. This disables the built in edit support for grid records. I've
replaced that using a links parameter with custom 'Edit' button linking to
my own edit record controller and view. This view omits 'Check to delete'.
If anyone knows a way to stay with the default behaviour of SQLFORM.grid
and remove the 'Check to delete' behaviour, OR to configure things so that
submitting with 'Check to delete' triggers the ondelete callback, I would
appreciate the help.
Thanks,
Robin
On Thursday, 4 May 2017 14:56:26 UTC+1, Robin Bryce wrote:
>
> Hi,
>
> Using web2py 2.14.6.
>
> In my controller function I have something like the following:
>
> def onupdate(form):
> log.info("updated %s", str(form.vars['id']))
> def ondelete(tbl, id_):
> log.info("About to delete %s", str(id_))
>
> return dict(grid = SQLFORM.grid(db.mytable, create=True, editable=True,
> deletable=True,
> ondelete=ondelete, onupdate=onupdate))
>
> (That is paraphrased, so there may be minor errors)
>
> This gives me a grid view with edit and delete buttons. If I click the
> delete button, ondelete fires as expected.
>
> If I click the edit button and then on the subsequent "edit" page, check
> the 'Check to delete' tick box and then submit, my record is deleted as
> expected, but it's onupdate that gets fired.
>
> Questions:
>
> Is this the expected behaviour ?
>
> How would I remove the 'Check to delete' tick box from the edit record
> page but retain the delete buttons on the grid view ?
>
> Alternately, what's the accepted idiom for checking if the update is
> actually a delete in the 'onupdate' call back ?
>
> Thanks,
>
> Robin
>
>
>
>
>
--
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.