admin管理员组

文章数量:1291130

We are migrating existing legacy Oracle Forms pages into the Oracle APEX pages.

On one of the page, we have an Interactive Grid with 3 columns: Role_Name (Display Only), Role_Description (Display Only) and Enabled (Checkbox).

On click (or on change) of a checkbox we would like to do some sort of PL/SQL checking and dynamically do the Role_Name ticked or unticked (Enabled column). For this we have to go through (loop through) the existing available roles and do check against each role.

We are stuck here, we don't know how can we check the current value of the role_name with other available role_name in a grid? How to implement this?

Your help and support would be appreciated.

We are using APEX v23.2.

I have attached the screen screenshot for your reference.

My IG

So far I have created a DA on a Enabled checkbox (On Change/On Click) - added True action Execute Server-Side Code. But then I'm stuck at looping through the IG.

PS: If you need I am happy to provide the Form's side code on Enabled column > WHEN-CHECKBOX-CHANGED.

We are migrating existing legacy Oracle Forms pages into the Oracle APEX pages.

On one of the page, we have an Interactive Grid with 3 columns: Role_Name (Display Only), Role_Description (Display Only) and Enabled (Checkbox).

On click (or on change) of a checkbox we would like to do some sort of PL/SQL checking and dynamically do the Role_Name ticked or unticked (Enabled column). For this we have to go through (loop through) the existing available roles and do check against each role.

We are stuck here, we don't know how can we check the current value of the role_name with other available role_name in a grid? How to implement this?

Your help and support would be appreciated.

We are using APEX v23.2.

I have attached the screen screenshot for your reference.

My IG

So far I have created a DA on a Enabled checkbox (On Change/On Click) - added True action Execute Server-Side Code. But then I'm stuck at looping through the IG.

PS: If you need I am happy to provide the Form's side code on Enabled column > WHEN-CHECKBOX-CHANGED.

Share Improve this question asked Feb 13 at 20:06 Bhavin AdhvaryuBhavin Adhvaryu 11 silver badge
Add a comment  | 

1 Answer 1

Reset to default 1

I would not use an IG for this pattern. Instead I would use a classic report (or interactive report). For the checkbox use an html expression with a custom button - show a different icon for checked and unchecked (for example font apex icons fa-check-square-o and fa-square-o). In the html expression include an apex action to fire an event to which you can bind a dynamic action to do your pl/sql checking. Then refresh the report with another action in the same DA. this SO answer is pretty similar.

Here is an example on how to something similar on the emp sample data table. The functionality is that the report has a column with an icon that shows an "up" arrow for users with job "PRESIDENT" and a "down" arrow for the others. When the "up" button is clicked, the salary of that employee is raised by 1. When the "down" button is clicked, the salary of that employee is lowered by 1.

Create a new page. In my example this is page 300.

Interactive Report

  • Create a region "Emp Report" of type "Interactive Report" with source
select EMPNO,
       ENAME,
       JOB,
       SAL,
       NULL as ACTION
  from EMP
  • Create a hidden page P300_EMPNO
  • For the "ACTION" column
    1. Type "Plain Text"
    2. Escape Special Characters: OFF
    3. HTML Expression:
<button type="button" title="My Button" aria-label="My Button" class="t-Button t-Button--noLabel t-Button--icon t-Button--noUI" data-action="raise_salary2?id=#EMPNO#">
<span aria-hidden="true" class="t-Icon fa
{case JOB/} 
    {when PRESIDENT/} fa-arrow-circle-o-up
    {otherwise/} fa-arrow-circle-o-down
{endcase/}"></span>
</button>

Dynamic Action/Javascript

On page attributes > Execute when page loads, set

apex.actions.add([        
    {
        name: "raise_salary",
        action: (event, element, args) => {
            apex.items.P300_EMPNO.value = args.id;
            apex.event.trigger(document, 'action-raise_salary');
        }
    }               
  ]);
  • Create a dynamic action "Change Salary"

    • Execution > Event Scope "Dynamic"
    • When > Event: "Custom"
    • When > Custom Event: action-raise_salary
    • When > Selection Type: Javascript Expression
    • When > Javascript Expression: document
  • Create a true action in the DA

    • Name: Update Salary DML
    • Action: Execute Server-side Code
    • PL/SQL Code:
UPDATE emp 
   SET sal = sal + CASE WHEN JOB = 'PRESIDENT' THEN 1 ELSE -1 END  
 WHERE empno = :P300_EMPNO;
  • Items to submit: P300_EMPNO

  • Create a true action in the DA

    • Action: Refresh
    • Selection Type: Region
    • Region: Emp Report

That's it. I suggest implementing this exact solution as a test and then modifying your code.

References:

  • apex.actions framework
  • button builder
  • template directives

本文标签: Oracle APEXLoop through an Interactive Grid and do PLSQL processStack Overflow