Page 1 of 1
How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Sun Nov 01, 2020 12:50 am
by mobhar
This following code will show you how to display the View/Edit page in modal dialog that belongs to another tables by using PHPMaker v2021. Actually, this trick is working also in v2020, but this time I obviously chose v2021, since I used the specific link to open the page in Modal dialog that only working in v2021 (which supports URL rewrite). If you want to implement this for v2020, then you need to adjust the url param from code below.
For simplicity, we need to use demo project that you may download and try by yourself for PHPMaker v2021: https://phpmaker.dev/demo2021.zip
So, we want to display Modal dialog to open View page of orders table for OrderID field from orders2 List page... and also open Edit page of customers table in Modal dialog for CustomerID field in orders2 List page.
Just copy this following code in Row_Rendered server event that belongs to orders2 table:
if (CurrentPageID() == "list" || CurrentPageID() == "view") {
$this->OrderID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"orders/view/".$this->OrderID->CurrentValue."\",btn: \"ViewBtn\"});'>" . $this->OrderID->ViewValue . "</a>";
$this->CustomerID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"customers/edit/".$this->CustomerID->CurrentValue."\",btn: \"EditBtn\"});'>" . $this->CustomerID->ViewValue . "</a>";
}
Don't forget to re-generate ALL the script files, as usual. ;-)
Now login using username/password: admin/master from the generated web application, then go to orders2 List page. As you can see, when you click on link in OrderID from orders2 List page, it will open View page of orders table in Modal dialog
The similar thing also for CustomerID; will open Edit page of customers table in Modal dialog from orders2 List page.
As always, happy coding, everyone! :-)
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Wed Jun 02, 2021 9:54 am
by inside83
It should not work in v 2018 or I'm doing something wrong?
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Wed Jun 02, 2021 10:25 am
by mobhar
This code is only for v2021. I am afraid that it does not work for v2018.
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Wed Jan 11, 2023 4:10 pm
by dirto
sorry, table is missing userlevel and userlevelpermisions
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 9:55 am
by totza2010
Does this code work for v2023?
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 11:15 am
by mobhar
Yes, it should work also for v2023 after doing some modification for the code.
This code:
$this->OrderID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"orders/view/".$this->OrderID->CurrentValue."\",btn: \"ViewBtn\"});'>" . $this->OrderID->ViewValue . "</a>";
should be:
$this->OrderID->ViewValue = "<a href='#' onclick='ew.modalDialogShow({lnk:this,url: \"orders/view/".$this->OrderID->CurrentValue."\",btn: null});'>" . $this->OrderID->ViewValue . "</a>";
In other words, this code:
btn: \"ViewBtn\"
should be:
btn: null
The other code remains the same.
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 12:51 pm
by totza2010
After testing it, it works, but when using Editbtn after editing the data. Content on that page will disappear.
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 2:11 pm
by mobhar
What did you mean by Content on that page will disappear? Did you mean the Modal dialog is closed and back to the List Page of orders2 table?
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 3:21 pm
by totza2010
When you press confirm The page where the button was created turned white with a message that edited successfully. This button is created on the viewing page.
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 3:43 pm
by mobhar
Did you enable Confirm option for Edit Page of customers table? In addition, did you setup Return Page after edit?
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 3:53 pm
by totza2010
in edit page for custom link use confirm. but not set return page.
Re: How to Display View/Edit Page in Modal Dialog that Belongs to Another Tables (v2021)
Posted: Tue May 09, 2023 4:30 pm
by mobhar
I cannot reproduce the issue.
I've just tried to enable Confirm option for Edit Page of customers table and then re-generate ALL the script files again.
In the generated web application, everything seems fine, after clicking on Save button, then system will display the Confirm button immediately, and after clicking one Confirm button, then data is saved properly, and Modal dialog is closed as usual.