Custom Javascript event on row update or delete

QuestionsCustom Javascript event on row update or delete
pcattani asked 4 years ago

Hi.  I have a page with three grids on it using three different tables.   The three tables relate to each other, with the middle table being a joining table.

e.g. Customers, Customers <–> Groups, Groups

Since the tables are interdependent, I need to be able to refresh the other two tables when one table is updated.

How can I generate a custom script which is triggered on update or delete of a record?

 

I tried:

 

$e[“js_on_delete_row”] = “do_delete”;

$g3->set_events($e);

 

But that didn’t seem to work.

Also, is there a quick way to refresh all the tables at once using Jquery?

 

I am using the premium version if any advanced features are needed.

 

Thanks in advance.

 

 

5 Answers
pcattani answered 3 years ago

Abu?

Abu Ghufran Staff answered 3 years ago

You can try these:
// for update callback, refreshes list1

$opt["onAfterSave"] = "function(){ jQuery('#list1').trigger('reloadGrid',[{current:true}]); }";

// for delete js callback

$opt["delete_options"]["afterSubmit"] = 'function(response) { if(response.status == 200)
{
jQuery("#list1").trigger("reloadGrid",[{current:true}]);
return [true,""];
}
}';
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
pcattani answered 3 years ago

Thank you very much!  I got the delete function to work:

 

$grid[“delete_options”][“afterSubmit”] = ‘function()
{
$(“#refresh_all”).click();
return [true,””];
}’;

 

I also got the update callback to work, but unfortunately there appears to be a bug.

This code will work:

 

$grid[“onAfterSave”] = ‘function() { $(“#refresh_all”).click(); }’;

 

So long as I click a row end then click the ‘Edit’ button, make changes, and save.

 

However, if I use in-line editing, it appears to interfere with saving the data.

In other words, if I use in-line editing of a row, make changes to a cell, and then click on the save button, the row doesn’t change.  Nothing appears to happen, but the Javascript console show this error:

 

“Uncaught SyntaxError: Unexpected end of input”

 

Is this an issue you’re aware of?  Is there a workaround?

 

Many thanks in advace.

 

pcattani answered 3 years ago

Update: I tried altering the function which is called when #refresh_all is clicked (a button).  This function reloads all the grid on the page, including the one being edited.

 

I thought the problem was that I was reloading the grid that I was editing, so I removed the reload on that grid.

 

Unfortunately, I still have the same error.

Abu Ghufran Staff answered 3 years ago

Hello,

Can you setup a remote session to see the issue.
You can email me at [email protected] and we can solve this case.

I am unable to understand the issue by provided details.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

10 + 4 =

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?