Oracle Apex: step by step approach to creating radio buttons in interactive report

后端 未结 2 1136
刺人心
刺人心 2021-01-06 03:32

Is there a good visual tutorial that takes through the various steps on how to create radio buttons in Apex 4.2? This tutorial Creating a Form in APEX to set Variables in a

相关标签:
2条回答
  • 2021-01-06 04:26

    For Apex 5 you have to change "Escape special characters" to "No" instead of changing the column property to "Standard Report Column":

    0 讨论(0)
  • 2021-01-06 04:31

    You could either use a column link to select the record and navigate to another page, or a radio button and a page button/link to do it. I'll demonstrate both using a simple report on the DEPT table.

    Method 1: radio button

    For the radio button we can add an additional column to the report using the apex_item.radiogroup function to create a radio button whose value is the DEPTNO:

    Report SQL statement

    By default, the HTML of the radiogroup will be escaped for security reasons, which is not what you want but illustrates what it is doing quite nicely:

    Report

    We can fix that by changing the column property to "Standard Report Column":

    Changing column type

    Now we see:

    Report after fix

    Clicking on the radio button on any row selects it and deselects the buttons on other rows.

    To navigate to another page with the selected row we need a button to submit the page with a special request:

    enter image description here

    enter image description here

    When clicked, that button will submit the page with a Request value of "SELECT" (the button name I chose). So we can write an on-submit page process to fire when the request is "SELECT", find out which radio button has been selected (if any) and save the selected DEPTNO to a hidden item called say P34_DEPTNO. We find out which button by looking at the APEX array apex_application.g_f01 which we chose by passing 1 as the first parameter to apex_item.radiogroup:

    if apex_application.g_f01.count > 0 then
       -- Array has been populated i.e. user chose a value
       :p34_deptno := apex_application.g_f01(1);
    else 
       -- Array has not been populated i.e. user did not choose a value
       :p34_deptno := null;
    end if;
    

    Then we can define a branch that navigates to the new page if (a) request = 'SELECT' and (b) P34_DEPTNO is not null.

    enter image description here

    And that's it. Quite a lot of work, but if that's the requirement that will do it.

    Method 2: column link

    The simpler way is to dispense with the radio buttons and just make one of the report columns into a link:

    enter image description here

    This turns the column (I chose DNAME) into a link that navigates to the new page taking the selected DEPTNO value with it:

    enter image description here

    That's it! No hidden item, no button, no page process, no branch...

    0 讨论(0)
提交回复
热议问题