Oracle APEX Tutorial 5 – Check Boxes – Part 2 – Video Training

kevin.landonTechnical TipsLeave a Comment

Introduction

Within APEX, there are a multitude of things you can use Check Boxes for, and many ways they
can be used to improve your application. This tutorial will focus on some of the things you can
use them for, as well as how to set their properties to make them work for you, not against you.
We recommend you review our article APEX Tutorial Preparation and OEHR Sample Data Install if
you haven’t already, as this tutorial requires the OEHR Sample Data to work properly.

Part 1 – Multi Value Check Boxes and Adding Check Boxes

[youtube]http://www.youtube.com/watch?v=SQzHdwfvt0Q[/youtube]

High Level Steps

1) Create Multi Value Check Boxes. (0:30)
2) Add Check Boxes to Each Row. (4:50)

Times in parenthesis are the approximate start times for those steps

Notes and Resources

Multi Value Boxes

What we are doing is creating a set of multi valued check boxes to serve as a way to filter
the returned data by category. Check boxes give us the flexibility to pick just what we want,
and not be limited to a single choice or preset combination.

Computation Explained

We create an odd computation and the purpose isn’t very clear. What we are doing is closing a
logic loophole in the behavior of the check boxes. If you were to deselect all the check boxes,
all the products would be listed, instead of none, due to how the logic works (deselected means
NULL< which means revert to default, which is Y, thus it’s on, even if off). By putting in this
computation, it essentially forces the system to remember the state of the check boxes.

APEX_ITEM

The APEX_ITEM is part of the system supplied packages that allow you to dynamically add certain
items as the page is processed. In this case, we are using it to create a ‘delete’ checkbox for
each displayed row.

Code and Entered Text

Label, Source Value and LOV for P1_REPORT_SEARCH

Product STATUS
obsolete:orderable:planned:UNDER development
SELECT DISTINCT product_status display_value, product_status return_value
FROM oehr_product_information
ORDER BY 1

Below is the new WHERE clause for the Product Report Source SQL Query

WHERE instr(':'||:P1_REPORT_SEARCH||':',product_status)&gt; 0

Computation and Expression 1 for P1_REPORT_SEARCH

NONE(bogus_value)
P1_REPORT_SEARCH

Form Element for P1_REPORT_SEARCH

class="fielddatabold"

New line to be added to the Region Source SQL Query for the Product Report Region

apex_item.checkbox(1,product_id) del,

Below is the PL/SQL code for the Delete Products Process

FOR i IN 1..APEX_APPLICATION.G_F01.count
LOOP
DELETE FROM oehr_product_information
WHERE product_id = APEX_APPLICATION.G_F01(i);
END LOOP;

Success and Fail messages for the Delete Products Process

Product(s) deleted.
Unable to delete product(s).

Leave a Reply

Your email address will not be published. Required fields are marked *