Press "Enter" to skip to content

Create Delete Row Button for Interactive Report in Oracle Apex

In this tutorial, I am giving a step-by-step example to create a delete row button for the interactive report in Oracle Apex. The functionality of delete operation would be, a delete button will display for every row in interactive report and when the user will click on the delete button, it will ask for the confirmation and if the user chooses Yes/Ok then it will delete the record from the database table and also it will delete the row from the interactive report and will refresh the report without submitting the whole page. To perform this task, follow these steps:

Create Delete Row Button for Interactive Report in Oracle Apex

In the below example, I have a report based on the customers and it has a primary key CUSTOMER_ID on that table and on the behalf of this column I will delete the row from the table. To test this example, you can use any table and primary key column or you can use also the ROWID.

1. Add One More Dummy Column to Interactive Report

Add one more column in your Interactive Report to use with the Delete button. I have added the column DEL as ‘Delete’. Below is the example query:

select CUSTOMER_ID,
       CUST_FIRST_NAME,
       CUST_LAST_NAME,
       CUST_STREET_ADDRESS1,
       CUST_STREET_ADDRESS2,
       CUST_CITY,
       CUST_STATE,
       CUST_POSTAL_CODE,
       CUST_EMAIL,
       PHONE_NUMBER1,
       PHONE_NUMBER2,
       URL,
       CREDIT_LIMIT,
       TAGS,
       ACTIVE_CUSTOMER,
       'Delete' Del
  from DEMO_CUSTOMERS

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=#CUSTOMER_ID#

Note: Change the CUSTOMER_ID with your report Primary Key column or the ROWID column, for example, data-id=#ROWID#.

Below is the screenshot of the above settings for your reference:

Oracle Apex Interactive Report Delete Row Button Settings.

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

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

  • Name: P26_CUSTOMER_ID (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

The jQuery Selector .delete-irrow is the class, which we have defined for the Delete button in the 2nd step. Below is the screenshot of the above setting:

Oracle Apex Dynamic Action jQuery Selector settings.

 

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

  1. 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?

1st True action Confirm.

  1. 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): P26_CUSTOMER_ID

2nd True Action Set Value.

  1. 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 demo_customers where customer_id = :P26_CUSTOMER_ID;
  • Items to Submit: P26_CUSTOMER_ID

3rd True Action Execute PL/SQL Code.

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

4th True Action Refresh.

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. You will have the output as shown below:

Oracle Apex interactive report output with delete row button.

Related Tutorials:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community OrclQA.com for developers and ask your question. It is FREE.

Vinish Kapoor

Follow

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

guest
22 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Rory Browne
Rory Browne
5 months ago

HI Vinish
I am new to APEX (using 19.2) and I find your blog to be a mine of amazing information. I love the way you describe in detail the steps to follow (for a new guy this is exactly what I want)

I wonder if you can help? I can see that you can set row highlighting on an IG and IR based on the value of a column in a row. I wonder if it is possible to show the row with strikethrough on each column when I delete the row?

What I mean is, if I use your example about deleting a row, say I just update an ACTIVE_IND column to be ‘N’? I’d like to see the row still showing in the grid, just with each column value with a strikethrough – something similar to what you get out of the box with IG (but IG removes the row from the grid)

Any help is much appreciated.

Regards
Rory

Rory Browne
Rory Browne
Reply to  Vinish Kapoor
5 months ago

Hi Vinish

Many thanks for the quick response. This worked just as I requested.

One final step now is to disable the DEL button when ACTIVE_IND column = ‘N’

Any suggestions?

Rory

Rory Browne
Rory Browne
Reply to  Vinish Kapoor
5 months ago

That was quick! 🙂

Many thank. I’ll give it a go

Rory

ZAKRIA
ZAKRIA
5 months ago

HI Vinish

please completed as almost as this copy but got error:
Ajax call returned server error ORA-01722: invalid number for Execute PL/SQL Code.

Gabriel Soler
Gabriel Soler
4 months ago

Hi Vinish
I did all the steps, but at the moment of executing the process nothing happens, the alert “Are you sure to delete this” jumps in screen but it does not make the delete and neither it refreshes the page

ZAKRIA
ZAKRIA
4 months ago

HI Vinish

Can we pass multiple page item in link attribute. if yes then how please help..

ZAKRIA
ZAKRIA
Reply to  Vinish Kapoor
4 months ago

many thanx 🙂

ZAKRIA
ZAKRIA
Reply to  Vinish Kapoor
4 months ago

THIS IS WHAT I WANT TO DO…

ZAKRIA
ZAKRIA
Reply to  Vinish Kapoor
4 months ago

I WANT VALUE AGAINST EACH PAGE ITEM NOT IN A ROW HOW TO SPLIT THEM PLEASE HELP MAN

suvankar roy
suvankar roy
3 months ago

How to delete row from interactive grid to follow the same as you define for interactive report.

NATH RANASINGHE
NATH RANASINGHE
3 months ago

Great Post.

najeeb alikhel
najeeb alikhel
Reply to  NATH RANASINGHE
2 months ago

it does not work on classic report for rowid what should we submit and plsql query
delete from table where rowid=rowid
how

Gabriel Gordo
Gabriel Gordo
2 months ago

Hi Vinish,

First of all thank you for the posts of APEX tecnology, I have followed some of them and thry helped me a lot while I was creting some of my applications.

This time I have a problem showing some notifications to the user. I followed this tutorial and I could delete without any problem the row I selected. The problem is I am trying to show a success or error message to let the user know the result of the process but when I tried to delete the row, my concurrent request was executed and ended correctly, but there was no result message.

So how could I show a message depending on the result of the concurrent request? For exmple, when the concurent request ends in COMPLETE status show success message and when it ends with WARNING or ERROR status show an error message.

I am now executing the concurrent request and trying to show the success message via the PL/SQL code in step 5.3.

Thank you very much.
Regards,

Gabriel.

Krish
Krish
2 months ago

Hi Vinish,
I need to create add row and Delete row button for each row in tabular form like your IR example. can you suggest. Thanks in Advance

Krish
Krish
1 month ago

How to add row in interactive report. Can you please suggest.
Thanks very much