Categories
APEX

Oracle APEX 26.1 IR Row Selector

It looks like it’s a small tweak, but it’s a highly significant enhancement that APEX 26.1 adds a native row selection for Interactive Reports. Previously this could be done in multiple ways, but it it really makes development a lot easier having this capability as a native component. In this article we are going to develop an application and see this in action.

Why Is A Selector Useful?

Interactive Reports are used heavily in APEX applications as they give the users great flexibility in being able to filter, sort, highlight, etc their data and see that data in different ways from the primary report that has been delivered by the developers. To be able to then select those filtered rows and then do something with those selected rows is a common requirement.

For this example we will use the EMP tables and select employees from one Interactive Report, and show the selected employees in a second Interactive Report on the same page in order to show how this new capability works.

Firstly let’s create an application and use the AI to do it.

What we are building

The page will have:

  • An Interactive Report showing employees
  • A Row Selector so the user can select employees
  • A hidden page item to hold the selected employee numbers
  • A second Interactive Report showing only the selected employees

That makes the feature easy to see and easy to test.

Generate the Application

Let’s use APEX 26.1 AI to generate an application based on the EMP table. We simply need to do this once we have got our chosen AI setup and see this prior article where we looked at the new narratives in IRs to do that ).

We will use the EMP table.

One of the options, as we expected, was an interactive report and it is this we will be using.

Review the suggested pages and create the application

The first thing we will do is to take a look at the initial generated IR in the page designer.

I can toggle the source from a straight select from the table to a SQL Query and when it generates the query ( as a “Select * from EMP” ) I can add a new null column that I will chose to act as the Row Selector. I’ll call it Row_Selector so that is obvious.

I can now look at the attributes of this column and by default it is a text column, but I will assign it the new type of Row Selector.

Doing that then pops up a bunch of additional options.

Enable Multi Select – We can select not just one but multiple records ( and this is where things get interesting!).

Show Select All – This gives us a checkbox at the top of the records where we can select all the records that are displayed.

Hide Control – Hide the checkbox displayed on each row.

I am going to allow multi select, allow select all and show the checkbox

The selected data ( which will be the column designated as the primary key ) will then be assigned to a page item. I will therefore create a new page item called P1_SELECTED_ITEMS

I can now go back to the Row_Selector column and allocate our new page item as the Content Selector Page Item. When the user selects records, the primary key ( in this case the EMPO will be stored in there ).

Running The Application

We have deliberately shown the page item so we can see how it is populated. In the example below when I select 3 rows, then the page item is automatically populated with 3 EMPNOs.

We can now interrogate that page item and “unpack” the selected primary key columns and use that in other processing. We’d have something like a button to invoke a process to say send these people an email or forward their data for additional processing. In this case we’ll create another IR to show the selected data and also that we can interpret the data stored in the page item. Below is the SQL we can use in the new IR, where we are selecting the employee data from the EMP table using the EMPNOs stored in the page item. As the key values are separated by a “:” then we can use that to split them up.

Let’s see this in action. Here I have selected 2 Employees for processing and then in the report underneath the page item values are unpacked and used to drive the second report.

Summary

The new native capability to select one or multiple ( or all ) records in a filtered IR is a great addition for developers as it provides a straightforward pattern to identify and record the key values of the items to be selected in a declarative manner. It is also easy to unpack the results and use them in downstream processing.