Introduction
Oracle APEX provides built-in dynamic actions that allow developers to perform basic interactions without writing custom JavaScript. These actions can be triggered by events such as clicking a button, changing the value of a field, or selecting an option from a dropdown. While these built-in features cover many everyday use cases, more complex interactions often require advanced JavaScript (or jQuery) to enhance functionality and provide a richer user experience.
This blog post will explore advanced JavaScript techniques for working with APEX regions, focusing on Interactive Grids. These components are powerful but sometimes require additional customization to meet specific requirements. By leveraging JavaScript, we can handle dynamic actions with jQuery Selectors and enhance Interactive Grids with custom validations, event handling, and dynamic modifications.
Let’s dive into how JavaScript can take APEX regions to the next level!
Basic JavaScript
Before beginning with Interactive Grids, let’s start with basic examples.
Accessing Page Items
For instance, we can use JavaScript to read or set the value of APEX page items. The functions $v() and $s() are commonly used:
-
Get the value of a page item:
-
Set the value of a page item:
Triggering Notifications
APEX provides built-in notifications using the apex.message namespace, which handles client-side display and management of messages.
-
Success Notification:
-
Error Notification:
Advanced JavaScript
As I said before, in the Introduction, we can handle dynamic actions with jQuery Selectors and enhance Interactive Grids with custom validations, event handling, and dynamic modifications.
In Oracle APEX, Dynamic Actions allows developers to create event-driven behaviour without writing complex code. One powerful way to trigger these actions is by using jQuery selectors. These selectors allow you to target specific elements within the DOM of your APEX page. You can handle a wide range of user interactions by combining dynamic actions with jQuery selectors.
A jQuery selector is essentially a way to find or select HTML elements based on their properties (like ID, class, tag, etc.) and then apply actions to them. This enables developers to interact with different components on the page in a flexible way.
Some types of jQuery Selectors in Oracle APEX
1. ID Selector (#)
-
It selects a single element with a specific ID.
Copy to Clipboard
2. Class Selector (.)
-
It selects all elements with a specific class.
Copy to Clipboard
3. Element Selector (Tag Selector).
-
Selects all elements of a specific HTML tag.
Copy to Clipboard
4. Attribute Selector
-
It selects elements based on the value of an attribute.
Copy to Clipboard
5. Descendant Selector
-
It selects elements that are descendants of a specific parent element.
Copy to Clipboard
6. Pseudo Classes
-
Select elements based on their state (e.g., checked, disabled, etc.).
Copy to Clipboard
7. Oracle APEX Specific selectors
In addition to the general jQuery selectors, Oracle APEX provides specific classes and IDs for interacting with its components:
-
Regions:
Copy to Clipboard -
Page Items:
Copy to Clipboard -
APEX Buttons:
Copy to Clipboard -
Interactive Grid:
Copy to Clipboard
Common JavaScript manipulations for IG in APEX
The Interactive Grid API in Oracle APEX allows developers to manipulate and customize interactive grids directly through JavaScript. This API enables dynamic operations such as adding, editing, or deleting rows, changing display settings in real-time, applying custom filters, and responding to specific user events. It facilitates the creation of richer user experiences aligned with business logic, optimizing data management and interaction in enterprise applications.”
This API extends the capabilities of interactive grids, providing detailed control over data and the interface in real-time.
-
Accessing the Interactive Grid API: You can access the Interactive Grid object using apex.region() and the region’s static ID.
Copy to Clipboard -
Getting the Current View Mode (Grid, Chart, etc.): Interactive Grids can have different views (Grid, Icon, Chart). You can get the current view type using:
Copy to Clipboard -
Refreshing the Interactive Grid: To refresh the data in the Interactive Grid, for example, after an update:
Copy to Clipboard -
Selecting Rows Programmatically: You can choose programmatically rows in the grid using the following code:
Copy to Clipboard -
Accessing the Selected Rows: You can access data from selected rows in the Interactive Grid like this:
Copy to Clipboard -
Updating Data Programmatically: To update data programmatically in a specific cell:
Copy to Clipboard -
Adding a New Row: You can add a new row to the grid with the following code:
Copy to Clipboard -
Deleting a Row: You can delete a row programmatically by:
Copy to Clipboard -
Save Data Programmatically: After making changes, you may want to save the data programmatically:
Copy to Clipboard -
Customizing the Toolbar: You can manipulate the toolbar of the Interactive Grid using toolbarData. Here is an example of how you might modify the toolbar to add a button:

Interactive Grid Region – Initialization JavaScript Function
Copy to Clipboard
This way, we Initialize the interactiveGrid with the toolbar data option specified in the Interactive Grid region Initialization JavaScript Function attribute.
-
Customizing action columns per row: You can add virtual columns to a grid to create actions involving the specified row.
In the following example, we create a new virtual column in our grid to set a button with different actions depending on the value of another column:

Custom ACTION column

Custom ACTION column visualization
Depending on the STATUS_CD column value, the button created will execute different actions:
Copy to Clipboard
The actions specified on the “onclick” event, will be declared on the “Function and Global Variable Declaration” section of the Page:
Copy to Clipboard
Conclusion
Customizing Oracle APEX regions with JavaScript, especially Interactive Grids, unlocks a world of possibilities for enhancing user experience and optimizing data management. While APEX provides a powerful set of declarative tools, integrating advanced JavaScript and jQuery techniques allows for more precise control over events, validations, and dynamic modifications.
By mastering these concepts, developers can create more intuitive, dynamic, and tailored applications without compromising performance or scalability. The key is to strike a balance between leveraging APEX’s native functionalities and implementing custom code, ensuring an efficient and maintainable solution.
Leave A Comment