Oracle APEX Interactive Report has default search option, where we can search the values which are exists in the report. Here I am giving an elegant method to highlight the cell of interactive report based on search criteria.
Step 1: Create a new blank page.
Step 2: Create a new Interactive Report region to the page.
Step 3: Set CSS Classes "data-highlighter" to the region.
Fig 1: Set CSS Classes
Step 4: Create a class by adding below CSS to the page in inline CSS section. It will change the style of report cells.
Go to Page => CSS => Inline
.highlight-data {
font-weight: bold !important;
background-color: #ffecb4 !important;
}
Step 5: Get a class for IR search component by following below steps.
- Place a mouse cursor on IR search component.
- Right click a mouse (The right mouse button is often used to open contextual menus, which are pop-up menus that change depending where you click) and select the menu "Inspect". DevTools pop-up comes up when we click on Inspect menu, from there we can get a class (JQuery Selector) for the particular components.
Fig 2: Get a Class
Step 6: Create a new Dynamic Action and set name to Highlight IR Cell that fires when key is released from IR search field.
Fig 3: Create Dynamic Action
Step 7: Set action to Execute JavaScript Code and copy and paste the following code into the JavaScript Code section.
// get the values from IR search field and make it to lower case
v_search = $('.a-IRR-search-field').val();
v_search = v_search.toLowerCase();
$(".data-highlighter td").each(function () {
// get the data from IR cell and make it to lower case
cellData = $(this).text();
cellData = cellData.toLowerCase();
// search IR search field value with IR cell data
cellData = cellData.search(v_search);
// class (highlight-data) should be defined in inline CSS section // if any match found in IR cells then add the class
if ((cellData != '-1' || cellData == 0) && v_search != '') {
$(this).closest('td').addClass('highlight-data');
}
// if no match found in IR cells then remove the class
else if (cellData == '-1') {
$(this).closest('td').removeClass('highlight-data');
} else
$(this).closest('td').removeClass('highlight-data');
});
Steps to Create Dynamic Action:
Event: Key Release
Selection Type: JQuery Selector
JQuery Selector: .a-IRR-search-field
True Action:
Execute JavaScript Code:
<<JS Code - Ref Sep 7>>
The demo is here.
That's it.
Happy APEXing!!!...
References:
The highlight is lost after pagination. Maybe hook into apexafterrefrresh event. Or maybe the intention is not to show the highlight after the search filter is applied? For IG there is an undocumented highlighter option, which you can see in action in the popup lov.
ReplyDeleteHi John,
DeleteYes, You are correct. Thanks for notifying me. Highlight should't lost even after pagination or filter applied. Let me change it, but Idea behind this post is to highlight the cell of IR when IR search field has a some values else the highlight will be lost.
Hello,
DeleteThank you for the good example (very interesting).
I gave it a try and still the issue with pagination (and filter setting) : as reported by John.
In the same time, it is perfectly working in you example. Could you please share the modification brought ?
BR
Sen
Sure, Let me try this and post it
Deletenice post.
ReplyDeleteSAP Grc training
SAP Grc online training
I really liked your Information. Keep up the good work. Body Code Practitioners
ReplyDelete