doomi
doomi

Reputation: 53

Conditional color of display only item - Oracle Apex 20.2

I'm new to Oracle APEX, using v.20.2

Scenario: I load a "Form" region via PL/SQL dynamically created SQL code depending on an instrument grid selections primary key and some dropdowns (going to different schematas).

What I want: Most of the "Items" in the "Form" are type "Display Only". Some of the values returned by the SQL are NULL. For two of them, I want to set the text for NULL values to 'N/A' and color them red. I want to avoid using javascript and build it with APEX internal possibilities as far as possible.

What I have already achived: I created dynamic events for Event "Change" for each of the two fields with client-side condition Item is null. For Result True I created action "Set Value" to static assignment N/A. This works well.

What doesn't work: I created an additional action "Set Style" with Settings "Style Name" = color and "Value" = red. This doesn't work. However when changing the field types of the affected fields to "Text Field" it works just fine (but then I (of course) get a warning about changed values when I try to leave the site - which would be actually desired for non-N/A cases).

Is this a bug, not possible at all for display only fields or does my approach have an error?

Thanks a lot in advance for some hints!

Upvotes: 0

Views: 2722

Answers (1)

Littlefoot
Littlefoot

Reputation: 143063

If I understood you correctly, that region is based on your PL/SQL procedure.

So, why wouldn't you do the job right there, in PL/SQL procedure? For example, this will display N/A instead of NULL:

select case when name is null then 'N/A'
            else name
       end as name
from ...

If you want to include colors, then

select case when name is null then 
                 '<span style="color:red">'  || 'N/A' || '</span>'
            else '<span style="color:blue">' || name  || '</span>'
       end as name
from ...

Doing so, you'd avoid dynamic actions. See if it helps.

Upvotes: 1

Related Questions