I’ve been looking through the docs and there are some quick solutions for after update or insert…
Is there a similar function for delete?
I am looking for something like:
$e[“on_after_insert”] = array(“after_insert”, null, false);
Except for delete. I would like to call a custom javascript function after the delete button is clicked.
If I need to replace the delete button, I could do that as well, but I need to know how I would get my custom function to do a normal delete operation, and then call my custom code afterwards.
Thanks
First, you can use on_after_delete same way you use on_delete / on_insert or on_after_insert. Difference is delete only gets row id to be deleted as parameter (not whole row data).
And in the callback function, you can write your custom delete logic and then push a message on client side with JS code. e.g.
function on_after_del_callback($data)
{
$g->execute_query(“DELETE FROM …..”);
// first param is message, second is autofade after 1 sec (0/1)
phpgrid_msg(“Record Deleted. <script>alert(‘custom js code’);</script>“,1);
die;
}
Let me know in case of any query.
Ref Code: https://www.gridphp.com/demo/demos/editing/bulk-edit.phps (line 150)
This will also work: