Link column in a IG with DA to update a table
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:
https://apex.oracle.com/pls/apex/f?p=4550:1
workspace: igtest
user: demouser
pass: apexdemo
Solution 1:
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 class="fa fa-check-circle-o raise_salary" 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.