Saturday, July 25, 2020

Delete Row Button for Interactive Report in Oracle Apex


1. Add One More Dummy Column to Interactive Report (City Details)

SELECT T.CITYID,
       T.CITYID AS CITYID_DISPLAY,
       T.CITYNAME,
       (SELECT C.COUNTRYNAME
          FROM COUNTRY C
         WHERE C.COUNTRYID = T.COUNTRYID)
          AS COUNTRYID,
       'Delete' Del
  FROM CITIES T
 
2. Set the Following Properties for the DEL Column

Type: Link
Heading: Delete
Target > Type: URL
URL: javascript:void(null);
Link Text: <span class="t-Icon fa fa-trash delete-irrow" aria-hidden="true"></span>
Link Attributes: data-id=#CITYID#

3. Create a Page Item to Hold the Primary Key Column Value

Now create a hidden page item to hold the primary key column P2_CITYID_H value. Do the right-click on the interactive report region and select Create Page Item option and set the following properties:

Name: P2_CITYID_H (set the name according to your page)
Type: Hidden
Value Protected: No

4. Create a Dynamic Action for the Interactive Report’s Delete Row Button

In Oracle Apex page designer, click on the Dynamic Actions Tab and do the right-click on the Click node and select Create Dynamic Action option and set the following properties:

Name: DA_DELETEROW
Event: Click
Selection Type: jQuery Selector
jQuery Selector: .delete-irrow
Event Scope: Dynamic

5. Create 4 True Actions for the Above Dynamic Action DA_DELETEROW

1st True action Confirm.
---------------------------------------
Do the right-click on the Dynamic Action DA_DELETEROW and select Create True Action option and set the following properties:
Action: Confirm
Text: Are you sure to delete this customer?

2nd True Action Set Value.
---------------------------------------
Create another True action Set Value below the Confirm action and set the following properties:
Action: Set Value
Set Type: JavaScript Expression
JavaScript Expression: $(this.triggeringElement).parent().data('id')
Selection Type: Item(s)
Item(s): P2_CITYID_H

3rd True Action Execute PL/SQL Code.
---------------------------------------
Create another True action Execute PL/SQL Code below the Set Value action and set the following properties:
Action: Execute PL/SQL Code
PL/SQL Code: Delete from CITIES where CITYID = :P2_CITYID_H;
Items to Submit: P2_CITYID_H

4th True Action Refresh.
--------------------------------
Create the last True action Refresh below the Execute PL/SQL Code action and set the following properties:
Action: Refresh
Selection Type: Region
Region: City Details (this is the interactive report region on my page)


The task is complete now, you have created the delete row button for the interactive report. Save the changes and run the page to test.


No comments:

Post a Comment

Delete Row Button to all records of Interactive Report in Oracle Apex

 1. add 'Delete' Del column to Report Query 2. Set the Following Properties for the DEL Column Type: Link Heading: Delete Targ...