How to reload grid in php event routine?

QuestionsHow to reload grid in php event routine?
Glenn asked 6 years ago

However, when in a event that is in a php routine what would that look like?
function update_groups(&$data){
global $list_main;
– do stuff here to update database tables

In javascript I would reload grid like this, but what can I do here?
$("#list1").trigger("reloadGrid", [{current:true}]);

}

7 Answers
Abu Ghufran answered 6 years ago

You can put reload option in inline:

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

For dialog,

$grid["edit_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{current:true}]); return [true, ''];}";

Glenn answered 6 years ago

Thanks Abu,
Sorry, I was not clear.
I meant reloading a different grid.
So you edit list1 and in the then you do a query to list2.
List2 needs to be refreshed.

list1 event
$aevent["on_update"] = array("update_groups", null, true);

function update_groups(&$data){
– do stuff here to update database tables that list2 comes from
– how to update list2?
}

Abu Ghufran answered 6 years ago

Ok, currently you cannot have JS reload code in on_update handler.
If you want to reload list2, in my previous reply, you can simply change list1 to list2.

And add onAfterSave and onsubmit options to list1 grid settings.

Glenn answered 6 years ago

Hi Abu,
Trying this again and still can not get it to work.

I changed one line of code in your demo master-multi-detail.php
http://websalesdesign.com/proj/lib/phpgrid-full/index.php
http://websalesdesign.com/proj/lib/phpgrid-full/demos/master-detail/master-multi-detail.php

I just put the line
$opt["onAfterSave"] = 'function() { $("#list1").trigger("reloadGrid", [{current:true}]); }'; // jqgrid_page:1
$grid->set_options($opt);

With this line Invoice data record will not save.
Is there another line I need to add. Was not sure what onsubmit option was.

Thanks
Glenn

Abu Ghufran answered 6 years ago

Perhaps, I am unable to understand the issue.

I tried editing grid row with grid header 'invoice data'
change amount from 100 to 1

It refreshed the top most grid, and make other detail grids blank.
i selected same row from top grid and it display changed record.

Please correct what i am missing.

Glenn answered 6 years ago

Hi Abu,
I tried it with the link that I sent to the code on my server and could not change any value in the Invoice Data grid.
I don't see any value of 1 so maybe you were using a different grid.

Abu Ghufran answered 6 years ago

Emailed you sample code.

Your Answer

7 + 11 =

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?