Is it bug or is it a feature? You tell me.
When you create a modal page in Apex 5, the title of the dialog is created before any change to session state. Dynamic titles, based on session state will therefore be funky.
Take this example.
1. Create a new page
2. Select as page type Form > Form on a Table with Report
3. next, next … until the Form page and set the property of the page mode to “Modal Dialog”
4. etc ect, finish
This creates a multirecord report with edit links.
When you click an edit link a dialog appears with the default title “Form on DEPT” (let’s say we had chosen DEPT as table).
But now I want to include the DEPTNO of the record in title. Set the property Title e.g. to “DEPT &P2_DEPTNO.”
Go to the report, click a record…. the deptno in the title is empty…
Go to the report, click another record… the title is not the deptno of the record you clicked, it is the former deptno.
Like I’ve said, is it a bug or a feature?
What happens:
The Apex team implemented the dialog page as an iframe within a jQuery dialog.
The links that are generated in the report look something like:
javascript:apex.navigation.dialog('f?p=x:x:x::NO::P1_DEPTNO:x ,{title:'DEPT ',height:'500',width:'720',maxWidth:'960',modal:true,dialog:null} ,'t-Dialog--standard',apex.jQuery('#Rx'));
And that is the problem in a nutshell. When the links in the report is generated, a JavaScript object is also generated for the dialog with e.g. the title as a property. This title is based on the current session state. However, the first argument, the link for the iframe, will alter session state to a new value. But that value is not propagated to the title of the dialog.
How to alter (solve?) this behaviour?
On the global page 0 I have created a Dynamic action, on Page load, executing the following JavaScript:
(function($){ if ( $("body").hasClass("t-Dialog-page")) { $(".ui-dialog-title", parent.document).html($("title").html()); } })(jQuery);
When in a dialog page, take the title of the page and replace the title of the parenting dialog.
The only issue I have with this solution is that sometimes you can see the title change. But still, it is better that nothing.
I stumbled across a similar solution, though things start to fall apart when you have other inline dialogs on the parent page.
I’ve gone with this so far on load of the modal.
parent.$(‘.ui-dialog-title’).closest(‘.ui-dialog–apex’).find(‘.ui-dialog-title’).text(‘your custom title’);
And you could default the title to “Loading…” :p
pragmatic, I like that…. but our customers won’t 🙂
just use APEX_UTIL.PREPARE_URL and REPLACE
replace the static Title with something from your sql-query
select replace(APEX_UTIL.PREPARE_URL(‘f?p=&APP_ID.:CARDS_MODAL:&SESSION.::&DEBUG.::P114_ID:’||ID),’title:”Blah”’,’title:”’||TITEL||””) from your_table
But please don’t use &SESSION. in your queries or you’ll flood the SQL pool. Use bind variable instead :APP_SESSION
How to add Maximize and Minimize icons to modal-dailog? I am using APEX 5.0.4. Please help me.
You may be interested in this, Rose
http://dickdral.blogspot.com.au/2016/12/automatic-resizing-of-modal-dialogs.html