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);
PL/SQL Code
begin delete from emp where empno = :P1_EMPNO; end;
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:
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:
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"

Add a true action of type Set Value:
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"
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.



