Search This Blog

Monday, June 30, 2025

How do I refresh a table with a button

 Introduction

In Oracle APEX, providing users with a seamless and responsive experience is key to building effective web applications. One simple yet powerful technique is allowing users to refresh a data table (such as a Classic Report or Interactive Report) by clicking a button. This is especially useful after inserting, updating, or deleting data, ensuring the displayed information is always up-to-date without requiring a full page reload. With Oracle APEX’s declarative features and Dynamic Actions, adding a refresh button is both quick and efficient.

In Oracle APEX, refreshing a table (such as a Classic Report, Interactive Report, or Interactive Grid) using a button can be achieved easily using Dynamic Actions. This is a very common requirement when users need to see updated data after performing actions like inserting or deleting records, or after applying filters. By wiring a button to refresh a region, you can ensure the data shown in your report or grid remains current without reloading the entire page.

To implement a refresh button for a report or grid:

1. Create or identify the report region to be refreshed
Make sure the region you want to refresh (Classic Report, Interactive Report, etc.) has a unique static ID.
To assign or verify the static ID:

  • Go to the Page Designer.

  • Select the region (e.g., your report).

  • In the Advanced section of the Property Editor, set a value for Static ID (e.g., report_emp).

2. Add a button to your page
You can place the button anywhere on the page.

  • In Page Designer, right-click on the region where you want the button (e.g., a region above the report).

  • Select Create Button.

  • Set the Button Name (e.g., REFRESH_BTN) and Label (e.g., Refresh Report).

  • Set Action to “Defined by Dynamic Action”.

3. Create a Dynamic Action for the button

  • In Page Designer, select the REFRESH_BTN button.

  • In the Dynamic Actions section, click Create Dynamic Action.

  • Set Name (e.g., Refresh Report Action).

  • Event: Click.

  • Selection Type: Button.

  • Button: REFRESH_BTN.

4. Define the True Action to refresh the region

  • Under True Actions, click Add True Action.

  • Action: Refresh.

  • Affected Elements:

    • Selection Type: Region.

    • Region: select the report region to refresh (e.g., Employee Report).

This setup allows the report to refresh dynamically whenever the button is clicked. The refresh process uses AJAX behind the scenes, so only the report region reloads, not the entire page.

Optional: Refresh After a Process
If you're inserting data via a PL/SQL Process and want the report to refresh immediately after, you can add a Dynamic Action on a button click or after a process completes, using the same method:

  • Use the “Execute PL/SQL Code” action, followed by a “Refresh” action.

This technique ensures a smooth and modern user experience while keeping your application's data accurate and instantly visible.

Example

The goal id to refresh a table after adding an entry to the table.

Step 1- Add a table region

A screenshot of a computer

Description automatically generated

Step 2 – Name the table

A screenshot of a computer

Description automatically generated

Step 3 – Select the table name

A screenshot of a computer

Description automatically generated

Step 4 – Add a second Dynamic Action to the button

  • Select The action: Refresh

A black and white text

Description automatically generated

  • Affected Elements

    • Selection Type: Region ( the report is a region)

    • Region: Newtable (the name of the report region)

A screenshot of a computer

Description automatically generated

Conclusion
Refreshing a table with a button in Oracle APEX enhances the interactivity and usability of your application. It helps users instantly view the most current data without navigating away or manually refreshing the page. By combining a standard button with a Dynamic Action to refresh the relevant region, you can provide a responsive and polished interface with minimal effort. This approach not only improves user experience but also maintains performance and clarity across your application pages.

No comments:

Post a Comment