💡 Enhancing Oracle APEX Cards with Dynamic Tooltips in Oracle APEX
🚩Introduction
By creating tooltip content using a SQL query and applying it to each card with a simple JavaScript snippet, developers can make the interface more interactive. This keeps the application clean, easy to use, and efficient.
📑 Why This Approach Is Needed
In Oracle APEX applications, Cards usually show summary data, but users may also need more details without overloading the interface. Using static tooltips for each card can be repetitive, hard to manage, and less flexible.
Using dynamic tooltips, generated from a SQL query and enhanced with a small JavaScript snippet, solves this issue. They provide relevant, context-based information for each card while keeping the application clean and easy to maintain.
This approach is useful when:
- You want to show extra details for each card without making the UI crowded
Tooltip content should change dynamically based on database data
You want to avoid hardcoding tooltip text for multiple cards
Any updates in data should automatically reflect in tooltips
The application should feel more interactive and user-friendly
This approach makes the application more flexible, easier to maintain, and improves the user experience with less code duplication.
👉 Use Case: Dynamic Tooltip for Cards in Oracle APEX
Step 1:
In the Page Builder, create one region and select the type as Cards and in the source section, select the type as SQL Query and copy paste the sample query below.
----- Card Source : SQL QUERY -----
select 11 as card_title , 'Tooltip : Card1' tooltip from dual
union
select 21 as card_title , 'Tooltip : Card2' tooltip from dual
union
select 31 as card_title , 'Tooltip : Card3' tooltip from dual
----- Card Source : SQL QUERY -----
select 11 as card_title , 'Tooltip : Card1' tooltip from dual
union
select 21 as card_title , 'Tooltip : Card2' tooltip from dual
union
select 31 as card_title , 'Tooltip : Card3' tooltip from dual
Step 2:
Step 3:
Next, under the Title section, select the card title column in the column attribute.

Step 4:
Now, in the Page designer, navigate to the Execute When Page Loads section and copy paste the below javascript code.
// Execute When Page Loads Section document.querySelectorAll('.a-CardView-item').forEach(function(el) { let data = el.getAttribute('data-id'); try { let arr = JSON.parse(data); // convert string to array if (arr.length > 1) { el.title = arr[1]; // second value (tooltip) console.log(el.title) } } catch (e) { console.error('Invalid data-id format', data); } });





Comments
Post a Comment