How to Set Page Items from a Classic Report Without Page Refresh in Oracle APEX

In Oracle APEX, you can create interactive classic reports that allow users to select a record and pass its values into a page item, without refreshing the whole page. One common case is setting an item like :P5_ID When a user clicks on a value (like ID) in a report.

Let’s explore how to do it using a custom SQL query and JavaScript. 

I have the following page :













On clicking the ID link column (right side), Department List, the left side populates, but the full page refreshes, I takes time when the table is big.

You can partial page refresh by changing the query from :

select
       ID,
       NAME,
       NAME_NL,
       SNAME,
       ENTRY_BY,
       ENTRY_DATE,
       UPDATE_BY,
       UPDATE_DATE,
       BRANCH
  from DESIGNATION;

It will refresh the Region :

select
'<a href="f?p=&APP_ID.:5:&SESSION.::NO::P5_ID:' || ID || '">' || ID || '</a>' AS ID,
       --ID,
       NAME,
       NAME_NL,
       SNAME,
       ENTRY_BY,
       ENTRY_DATE,
       UPDATE_BY,
       UPDATE_DATE,
       BRANCH
  from DESIGNATION;

It will not refresh anything, not even the region, because of
using JavaScript:

select
'<a href="javascript:$s(''P5_ID'',''' || ID || ''');">' || ID || '</a>' AS ID,
       NAME,
       NAME_NL,
       SNAME,
       ENTRY_BY,
       ENTRY_DATE,
       UPDATE_BY,
       UPDATE_DATE,
       BRANCH
  from DESIGNATION

The above query will set value to the item :P5_ID from ID in the query.

Now set dynamic action at :P5_ID 


True Action :

Additional Setup

  1. In the Classic Report column settings for ID (link) :

    • Set “Escape Special Characters” to No.

  2. Make sure the page item P5_ID exists on the page.


PLSQL CODE DYNAMIC ACTION :

BEGIN
  SELECT NAME,NAME_NL,SNAME 
  INTO   :P5_NAME,:P5_NAME_NL,:P5_SNAME
  FROM DESIGNATION
  WHERE ID=:P5_ID;
END;

ITEMS TO RETURN : P5_NAME,P5_NAME_NL,P5_SNAME
ITEMS TO SUBMIT : P5_ID

--------------------------------------------------------------

Control Button by Javascript. Use case in Dynamic Action.

First Set Button Static ID

  1. Go to the button's properties in Page Designer.

  2. Find Static ID under Advanced section.

  3. Set it to something like: SAVE or CREATE

Example JavaScript to Control Buttons

🔹 Enable the Save button:
$('#SAVE').prop('disabled', false); // Enable
🔹 Disable the Create button:
$('#CREATE').prop('disabled', true); // Disable

Replace 'SAVE' and 'CREATE' with the Static ID of your buttons, not their names or labels.

Optional: Show/Hide Instead of Enable/Disable :

If you prefer to show/hide:

$('#SAVE').show(); $('#CREATE').hide();


Muhammad Abdullah Al Noor

Muhammad Abdullah Al Noor, An Oracle Apex Consultants and founder of Noors Technology (www.noorstech.com). Core Expertise : Database Administration, Oracle Forms and Reports Development, Oracle Apex Application Designer and Development, Linux Professional etc. Also the owner of TrainerBD Training and OraDemy E-Learning. WhatsApp +8801790721177

Post a Comment

Previous Post Next Post