I see there are many questions on the workings of *ondelete* and 
*oncreate*callbacks of the grid and smartgrid, but I can't find a valid answer.
The book says that all but *ondelete* take a form object as input.
Searching for answers in:

   -     grid/smartgrid ondelete 
issue<https://groups.google.com/forum/#!searchin/web2py/smartgrid$20ondelete/web2py/nB75AqfLXzU/ceF7bcc_PjYJ>


   -     Re: [web2py] Re: SQLFORM.smartgrid oncreate,ondelete not firing 
   
<https://groups.google.com/forum/#!searchin/web2py/smartgrid$20ondelete/web2py/unh5RipqbNo/K16k9Z9jiPIJ>.
  
   Here a format of: def myondelete(table, row_id):... is advised. But then 
   why the book doesn't mention the ondelete other arguments, i.e. table and 
   row_id?


   -     Examples for SQLFORM.grid oncreate, onupdate, 
ondelete<https://groups.google.com/forum/#!searchin/web2py/smartgrid$20ondelete/web2py/1TgXsgcmZoc/piunZYCUF9kJ>Here
 an example is given for a oncreate function, which still doesn't seem 
   to fire in my case. Having some 'print' inside these callbacks, doesn't 
   produce anything for some reason...


The code at sqlhtml.py (1928 line) is:

        elif deletable and len(request.args) > 2 and request.args[-3] == 
'delete':
            table = db[request.args[-2]]
            if ondelete:
                ondelete(table, request.args[-1])
            ret = db(table[table._id.name] == request.args[-1]).delete()


which doesn't have any:

    request.args[-3] == 'delete'



Still, if I don't define an *ondelete* function, the row is deleted 
properly by pressing the 'Delete' button. If I do declare a *ondelete*callback, 
the
row again is removed from the interface, but having a refresh, the 
'deleted' line is back on!

In my case the link that the Delete button is pointing to is:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1?_signature=dfc73167259232e58a520cbf7a60d8d52e783fbb#null

Which I think is wrong, because it is the same for all my listed samples. 
E.g. All the links of the Delete buttons point to the same direction!!
However the adjacent Edit button (e.g. for sample 4) is pointing to:
http://127.0.0.1:8000/lims/default/my_analyses/analyses/samples.analysis/1/edit/samples/8?_signature=55fe76676f0c1f9f97ee30d710af231e317d8b3e
Which is different for every Edit button of my rows.

 
It would be great, If someone could provide some clear explanation, and a 
working example, of the *ondelete* and the *oncreate* callbacks...

-- 



Reply via email to