This topic is locked

Refresh DETAILS list page after edit in popup

2/14/2018 10:25:20 AM
PHPRunner Tips and Tricks
F
FunkDaddy author

So the documentation gives us instructions on how to refresh list page after edit in popup as seen here: https://xlinesoft.com/phprunner/docs/how_to_refresh_list_page_after.htm
However, the example given DOES NOT work when you have a details list page INSIDE a popup. The browser console will return a 'rndVal' of undefined error message!
So here is the fix as provided to me directly by Sergey:
In the list page of the details table you have embedded in your popup form add this to JsOnLoad event:



if (window.od==undefined) {

window.od = [pageObj];

} else {

window.od.push(pageObj);

}


Then in the popup form (the parent) add this to the JsOnLoad event (either in edit or add popups)...MAKE SURE you replace the your_example_details_list.php below with your details list page instead (and also if using "add new" button inside details replace 'afterInlineAdd' with 'afterSave' in the method call:



this.on('afterInlineAdd', function( fieldsData ) {

if (od!=undefined) {

for (var prop in od) {

Runner.runnerAJAX('your_example_details_list.php?a=a', od[prop].baseParams, function(respObj) {

od[prop].pageReloadHn(respObj);

});

}

}

} );


Voila, you now can get instant refresh of detail inside a popup :-)

F
FunkDaddy author 2/15/2018

I am adding to this post to help anyone else who may have ALSO run into another semi-related issue that results in edit page in popup not being able to refresh list page via ajax after save.
It turns our that if you have a details page also present in the main list page, and both those list pages are using the refresh code (see "How to refresh List page after Edit in popup" in the PHPR docs), then you will also receive a console error message and the popup edit page wil get "stuck" on page (wont close) and list page will not refresh either.
To solve this problem you should assign unique variable names to each list page (parent and then detail) to prevent conflicts. The code given in docs tells us to simply add "window.listPage = pageObj;" to the list page... however, instead you should give it a unique name such as window.listPage_parent_table_name = pageObj; and then window.listPage_child_table_name = pageObj;.
You should then, also change the code in each of the add/edit pages to reflect use of the unique variable in their respective pages. So you would then change inside the "this.on('afterSave', function() {" the first line from: var pageObj = window.listPage; over to: var pageObj = window.listPage_parent_table_name ;.. then same logic applicable to child add/edit je events where you refer to the var set on the list page for them.

D
dpst813 10/18/2019

This works great but I have one issue. I have noticed after the grid reloads on an Add or Edit Page. If the row was a popup instead of a new tab it opens in a new tab. Any thoughts on this? Thank you.