Viscosity
logo-black
  • Data
    • Database Services
      • Performance Assessment
      • Proactive Healthcheck
      • Database Migration & Consolidation
      • Performance Tuning
    • Microsoft Services
      • Microsoft Azure Services
      • Microsoft SQL Server Services
      • Microsoft Gold Azure Partner
    • Oracle Services
      • Oracle Database 19c
      • RAC
      • GoldenGate
      • Data Guard
      • Oracle & SQL Database
    • Viscosity Remote Services
  • Apps
    • App Dev Services
    • Oracle APEX
    • Viscosity AMP
    • Viscosity-ai
    • Shane-ai
  • Cloud
    • Cloud Services
    • Hybrid Cloud
    • Viscosity Edge Cloud
    • Virtualization & Cloud Expertise
    • Microsoft Azure Services
  • Infrastructure
    • Infrastructure Services
    • Exadata
      • Exadata Resale & Services
    • Oracle Database Appliance
      • Oracle Database Appliance Resale & Services
      • ODA Health Checks
    • Zero Data Loss Recovery Appliance
    • VMware to KVM Migration
  • Events
    • Upcoming Events
    • Virtual Training
    • 2025 Past Events
    • 2024 Past Events
    • 2023 Past Events
    • 2022 Past Events
  • About
    • About Us
    • News
    • Blogs
    • Publications
    • Contact
Hit enter to search or ESC to close
ENGAGE WITH US

Conditional Highlighting Grid Data

By Alan Quigley
September 02, 2022

Sometimes you need to add some color to your grids. When sifting through your data, that color pop can add some visibility to your data. Color can add a quick view into what your data is saying. The best way to accomplish this in APEX is through some fairly basic JavaScript and CSS.  

 

Highlighting Interactive Grid Cells

 

Start by adding this code to the Function and Global Variable Declaration.

Code Editor - punctbn aM GI&I V"tAe (klaration 
unctW' { 
N/ for 
,highlight { 
cellData - 
if 
cc.ics•) 
this. style. 
if (cellData 
if (cellData 
Cæics•) 
else If publishing • ) 
this. style.back8roundColor •green • ;

 

function highlight_ig_cells() { 

    // Get the cells from the marked grid 

    $('.highlight td.column').each(function() { 

        // get the cell text 

        cellData = $(this).text(); 

        // rules for coloring based on the cell text 

        if (cellData === 'DC Comics') 

            this.style.backgroundColor = 'red';    

        else if (cellData == 'Marvel Comics') 

            this.style.backgroundColor = 'blue';  

        else if (cellData == 'Image Comics') 

            this.style.backgroundColor = 'purple'; 

        else if (cellData == 'IDW Publishing') 

            this.style.backgroundColor = 'green';                   

    }) 

};

 

This will get the data from the marked cells. Now we will need to tell this function which cells to get. 

First, we will add a CSS class to the grid itself. It will tell the function which grid to look at. This will be done on this line of code: 

 
$('.highlight td.column').each(function() 

 
We will want to add this ‘highlight’ tag to the CSS call on the Grid under Appearance.

TMT@Me 
TMT@Me 
htM•ctive Re-port 
Ca•tent 
TMn*te Maults

 

To mark the cell that you want to highlight, we look to the second part of the code above. 

 
$('.highlight td.column').each(function() 

 
We will want to mark the column in the same manner. This will be on the column in the Grid under Appearance as before.

 

Now that everything is marked, we will need to call the function. We are going to add this to the JavaScript Execute when Page Loads.

hi-Olin—ig-cells();

 

Now this will highlight when the page loads, but we need to add a dynamic action to handle when the grid loads more data. We will want to create one for Page Change [Interactive Grid] on the grid Region.

 

The True Action will be a JavaScript Expression to call that same highlight_ig_cells(). 

saumas 
ap03 
uoueułuuapł

 

That will now highlight the cells based on the logic, even when the grid is refreshed or changed.  This is a very simple and easy to maintain process that will give you and your users easy to read visual representations of your data.   

All posts
About Author
Alan Quigley

Alan Quigley is a Senior Software Architect at Viscosity, with almost four years of invaluable expertise to the role. He has over nine years of specialized experience in Oracle APEX and more than twelve years of honing his skills in crafting complex logical solutions. Alan has made a significant impact in diverse industries such as Accounting, Supply Chain, Logistics, Healthcare, and Utilities, thanks to his exceptional command of PL/SQL and Oracle APEX. He is an undisputed expert in these domains, consistently delivering innovative, efficient, and robust software solutions that redefine industry standards.

SUBMIT YOUR COMMENT
logo for footer

Viscosity's core expertise includes:

Data Transformation, Emerging Technology, High Availability & Scalability Solutions, Cloud Migrations, Performance Tuning, Data Integrations, Machine Learning, APEX Development, and Custom Application Development.


Solutions

Resources

Partnerships

Careers

Clients

 

Contact
Email: sales@viscosityna.com

Telephone:
(469) 444-1380

Address:
3016 Communications Pkwy Suite 200, Plano, TX 75093

Copyright 2025. All Rights Reserved by Viscosity North America.