I've worked around this by tackling the issue a different way:

- disable the delete button on the grid altogether with deletable=False
- selectively enable it in edit mode for records that are safe/appropriate to delete

Maybe I should have done it this way to begin with - as it is nicer if the user only sees actions that are going to work.

On 14/02/12 13:11, Mark Kirkwood wrote:
I am attempting to implement a check that allows deletes only under some circumstances. I figured I would do this via the ondelete arg in the grid. Unfortunately I have run into a few stumbling blocks with this:

1/ The 1.99.4 code is busted - references 'ret' before it is defined

Fortunately a simple fix (I think you guys have done something like this in trunk) -

sqlhtml.py:1294
            if ondelete:
                #ondelete(table,request.args[-1],ret)
                ondelete(table,request.args[-1])

2/ The ondelete function is only called from the main grid delete action, not the delete checkbox in edit mode

I would be great if the logic could be applied there too - otherwise I guess I can workaround by switching the delete option off in the edit screen.


3/ Am unclear about how to signal back that I want delete to stop

I figure I am just being dense in this case, but ondelete function accepts table and row id variables (not a form) so I don't see any way to set the form's error status.

Thanks for your help

Mark

Reply via email to