4
votes

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 Query for an Interactive Report helped me in creating forms and I’m looking for a similar one.

Within my application, I would like to add a radio button to each row of my interactive report which when selected would take the user to another report combining different tables?

Any advice is much appreciated.

Thanks

2
Do you mean radio buttons? Sounds like you rather want a link on each row to take you to a another report page?Tony Andrews
@TonyAndrews Yes I do mean radio buttons. Is a row link possible? The reason why I want radio buttons is because when the user selects a customer's name and booing order number from the interactive report, after their details are collected from a from, it should take them to another report where it should show their address details and their booking order details. I'm new to apex so any guidance is much appreciated.tinlin28
Yes a link is certainly possible - just edit the report column and fill in the Column Link properties. By radio buttons, do you mean use a radio buttons to select the row before linking off to another page by clicking on a button or link elsewhere on the page? That is also possible, though not as easy as just creating a column link.Tony Andrews
I tell you what - as we seem to have a time zone difference, I'll write an answer showing both methods...Tony Andrews

2 Answers

12
votes

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...

4
votes

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

enter image description here