Skip to main content

Command Palette

Search for a command to run...

Oracle APEX - Dynamic Table Cell Colour

Using CSS (no jQuery)

Updated
1 min readView as Markdown
Oracle APEX - Dynamic Table Cell Colour
D

I ❤️ Oracle APEX

Using the following query as our example

select
  column_a,
  case when column_a = 1 then 'Y' else 'N' end as column_b
from table_name;

HTML Expression for table column. Note the use of substitution strings.

<span data-value=#COLUMN_B#>#COLUMN_A#</span>

CSS selector used to target our td with the data-value attribute, derived from the initial query.

td:has(> span[data-value="Y"]) {
  background-color: #BADA55;
}

data-attributes in CSS - daily-dev-tips.com/working-with-data-attributes-in-css

The :has() pseudo-class - developer.mozilla.org/CSS/:has