How to call javascript function after row deletion?

QuestionsHow to call javascript function after row deletion?
pcattani asked 3 years ago

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

 

2 Answers
Abu Ghufran Staff answered 3 years ago

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)

Ref: Grid Events – Grid 4 PHP Framework Docs (gridphp.com)

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Abu Ghufran Staff answered 3 years ago
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

7 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?