Home > Software engineering >  Link column in a IG with DA to update a table
Link column in a IG with DA to update a table

Time:01-20

How to create a link column in Interactive Grid to execute dynamic action ?

I created a demo app to delete employee from emp table where I have a DA with 4 steps:

1.Confirmation

2.JavaScript Code

var empNo = $(this.triggeringElement).attr('href');
apex.item('P1_EMPNO').setValue(empNo);
  1. PL/SQL Code

    begin delete from emp where empno = :P1_EMPNO; end;

  2. Refresh region

It doesn't work at all, when I click on the link column it does nothing

I created a demo app, I would appreciate any advice:

enter image description here

EDIT: When I deeply checked your demo app, I saw that you are using the EMPNO column of type link and setting the link with #EMPNO#. This means this link is trying to go to the URL: enter image description here apex.oracle.com/pls/apex//#EMPNO# which is not valid. Either change link URL to a valid modal confirmation dialog page you would create, or remove the link so that dynamic action would be triggered.

CodePudding user response:

Here is one way to do it. This was on my environment, not yours. It is an editable IG report on the emp table, page 55. The functionality is that when a link is clicked the salary is increased by 1.

Short explanation of this technique:

  • Set the data attribute of link to "EMPNO" so it can be read by javascript
  • Use a class to capture the click event
  • Trigger an event when link is clicked
  • Listen for that event and execute the pl/sql code.

1. Add a link column to the report. I used the "Create Column" option of the report to add a column of source type "SQL Expression" with sql expression: '<span aria-hidden="true" data-empno="'||EMPNO||'"></span>'

2. Add dynamic action "Raise Salary Clicked", Event scope "dynamic" enter image description here

Add a true action of type Set Value:

enter image description here

Add a true action of type Execute Javascript Code:

Action: Execute Javascript Code

Code: $.event.trigger("raisesalary");

3. Add a dynamic action "After raisesalary event", Event scope "dynamic"

enter image description here

Add a true action of type "Execute Server-side Code":

PL/SQL Code: UPDATE emp SET sal = sal 1 WHERE empno = :P55_EMPNO

Items to submit: P55_EMPNO

Add a true action of type "Refresh" to refresh the interactive grid region.

  •  Tags:  
  • Related