Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
Auto Refresh Grid

I would like to auto refresh 1 or more Interactive Grids or Reports on a page every so often.
I'm using setInterval("jQuery('#grdMyGrid').trigger('apexrefresh');", 15000); which works. But this grid has a link that opens a modal. When the modal is open and it refreshes again, it closes the modal.
Is there a way to only refresh if a modal is not open?
Or refresh the grid without it closing the modal?
Answers
-
Hello Chad L,
Set your IG or IR
Static Id
attribute e.g. emp then edit your JS Code as follow :setInterval(function(){ apex.region('emp').refresh(); }, 15000);
Hope this helps!
Regards,
Hamza
-
Let's assume 2 things...your modal is not in the DOM when it isn't visible, i.e. it is created on the fly, and that your modal has a static ID that we can reference. For this, let's call it "MyModal".
setInterval( function() { if( $('#MyModal').length = 0 ) { apex.region('grdMyGrid').refresh(); } }, 15000);
If your modal stays in the DOM but, simply becomes invisible, then this code should do it:
setInterval( function() { if( $('#MyModal').css('display') = 'none' ) { apex.region('grdMyGrid').refresh(); } }, 15000);
Cheers,
-Joe
-
That works, but seems to worth the same as the way I had.
I incorrectly said the refresh closes any open modal when it refreshes. It doesn't close the modal. But it does mess up an current editing on the modal. If the user is in the middle of editing, it's like it removes the cursor.
I think what I really need is to only refresh when there is no modal open.
-
Thank you for your response.
I don't see where a modal page has a Static ID. I did try it, checking for the existence of a grid that exists on that modal page. But I get an error. "Uncaught Reference Error: Invalid left-hand side in assignment" every time it fires. Whether the modal is up or not.
In the (base page) Function and Global Variable Declaration, I have:
setInterval(
function()
{
if( $('#grdPES').css('display') = 'none' )
{
apex.region('grdBreakdowns2').refresh();
}
},
5000);
-
So, if you don't have a static ID, then using will not work. It doesn't have to be a static ID. Any jQuery selector will do. You don't mention exactly how you are presenting your modal window but, assuming you are using a page with a Page Mode of "Modal Dialog," this selector will work fine:
$('div[role="dialog"]')
(Also, assumes you just have one modal dialog on the page). Slight bug in my JS there 😏. The equal sign is wrong for an if evaluation. Sorry about that...was typing on the fly. Assuming our new selector works, use this:
setInterval( function() { if( $('div[role="dialog"]').css('display') === 'none' ) { apex.region('grdBreakdowns2').refresh(); } }, 5000 );
-Joe