Perform Additional Processing When Modal Pop-Up Window Closes
Bryan Patrick –Pseudo Consulting
August 16, 2014
Iron Speed added an excellent feature in version 11: The ability to open any window in a modal pop-up window. This feature also allows the application to automatically update either one record or one table when the pop-up window closes. Here’s how to perform other processing when the user closes that modal pop-up window.
In one of my applications I have “Edit Account” page where I’ve grouped many fields onto different tabs. One of the tabs contains an “Account Ledger” table of transactions. The problem is that by default the “Add Record” page for this table redirects to a new browser window. If the user had updated any field prior to clicking on the “Add Record” icon those changes will be lost. Sure, we could have modified the button to save the record before redirecting but I don’t want to save changes unless the user clicks on the “Save” button.
The Solution to the Problem
Along comes Iron Speed version 11 and aha! They’ve added the ability to open the “Add Record” page in a modal pop-up. Excellent! I won’t lose my record changes while I’m adding a new Ledger Transaction. And after adding the record, the Account Ledger table is updated on the tab. And this works very well.
The ledger table after the “Save” button is clicked in the modal pop-up
The Problem with the Solution to the Problem
The problem with this is that on the first tab of the user’s record, I show an “Account Balance” which is the sum of all the user’s transactions. Updating just the ledger table does not update any other control on the page. So I needed a way to update both the ledger table and another control when the user adds a record. Unfortunately, the function that is called by user closing the modal pop-up is declared “Private” so it cannot be modified or overridden in your record or table classes.
The Solution to the Problem with the Solution to the Problem
We can simply modify the “Postback” function and make it public. Then with a couple of lines of code, we can perform other functions when a modal pop-up window closes.
Open the \shared\BaseApplicationRecordControl.cs and scroll to the bottom of the file. Change the Postback function to be public virtual. This is the function that handles updating a record control when a pop-up window closes.
Do the same with \shared\BaseApplicationTableControl.cs. This is the function that handles updating a table control when a pop-up window closes.
Then it’s just a matter of adding the override code to your record or table class. In my case, the table class for the ledger is “OnlineLedgerViewTable”. In the overridden function, I call the base function (to update the ledger table itself). I then locate the record control on the page that is displaying the Account Balance and set its “DataChanged” to true, which will cause it to also be updated.
Now the numbers on the “General” tab are updated whenever a ledger entry is added. No other fields are updated/overwritten.
Modifications to the “baseclasses” will get overwritten the next time you migrate your application to a newer version of Iron Speed.
With a little modification to the base classes it’s possible to perform additional processing when the user closes a modal pop-up window in an Iron Speed application. In this example I’m just updating some other information on the same underlying page. You can perform any processing you want.
Hopefully in the future, the base classes will define “Postback” as public so they can be overridden without having to modify anything.
About the Author
C. Bryan Patrick II has been a professional database developer since the age of 16. He has a Bachelor of Arts in Computer Science from The University of Texas at Austin. At 26 Bryan received a US Patent (# 5,142,624) for work done during his college years. He is a member of the Microsoft Partner Program and has been self-employed for the last 14 years as a web application developer.