OverView

This document talks about how to hide and show the elements in oracle apex using JavaScript.By the following method, we can hide and show the oracle apex region, button, and item based on the condition.

Technologies and Tools Used

The following technologies have been used to achieve the expected output.

Ø JavaScript

Use Case

We can achieve this hide and show feature using dynamic action in the oracle apex by default. In this method, we can use normal conditions. We can not use the complex conditions in these methods. So, we are going for JavaScript to achieve the complex condition scenario.

Assume that there is a requirement to hide and show the button, item, or region based on the complex condition. For that, we can use this JavaScript method to hide and show the button, item, or region.

This document explains how to achieve this requirement.

Architecture

We are having the page as below on that we are going explain how to hide and show the button, item, and region based on the condition.

The following steps explain in detail,

Hide and Show the Region

Step 1:

As a first step, we need to add the static ID as Cust to the region which we want to hide and show based on the condition. Here we are going to hide and show based on the item is empty and not empty.

Step 2:

We are going to add the below JavaScript code in Execute when the page loads in the page properties.

Sample Code

if (apex.item(“P3_CUSTOMER_NAME”).isEmpty()) {

$x_Hide(“cust”);

} else {

$x_Show(“cust”);

}

Like this, we can hide show the Button and Item. To hide and show the Button we need to add the static ID to the button. To hide and show the item we do not need to add a static id. We can hide and show using the item name itself. We can use the below codes for example.

SBT – Static ID of Button

P3_CUSTOMER_ID – Item Name

if (apex.item(“P3_CUSTOMER_NAME”).isEmpty()) {

$x_Hide(“SBT”);

} else {

$x_Show(“SBT”);

}

if (apex.item(“P3_CUSTOMER_NAME”).isEmpty()) {

$x_Hide(“P3_CUSTOMER_ID”);

} else {

$x_Show(“P3_CUSTOMER_ID”);

}

ScreenShot

Output:

Based on the Customer name field values the report region is hidden.

Recommended Posts

Start typing and press Enter to search