Search code examples
cssoracleoracle-apexlov

How to colour a column differently depending on value


I am trying to create a column in a report which would take entries from a corresponding column from the database. This LOV is returning the active or inactive status depending on the value of the base column.

I would like to add colours to this column so it could be easier to spot records where the status has been set to inactive. So, green for active and red for inactive.
Any help greatly appreciated.


Solution

  • IR region source

    select * from emp
    

    Made an LOV on deptno LOV on column deptno

    Run the report. Go to Actions > Format > Highlight actions format highlight

    On the highlight options you can specify colours, whether to highlight the row or just a cell, and the condition for the highlight. Note that for lov columns you can pop open an lov with the values for that lov through the arrow button next to the expression field! highlighting options

    Applying this will result in this: highlighting results

    If you want this applied by default do not forget to save your report!


    If highlighting is not to your satisfaction, you can still go the javascript / CSS way.

    Create a dynamic action to fire after refresh of the IR region, with a true action of type Execute Javascript.

    $("#apexir_DATA_PANEL td[headers='DEPTNO']").each(
    function(){
       if($(this).text()=='ACCOUNTING'){
          $(this).addClass('deptAccounting'); //great to keep style in CSS! 
          $(this).css({"background-color":"red"}); //for that quick fix
       }
    }
    );
    

    Note that for this you need to specify the column (headers) and have to code in the to-be-compared text!