This discussion is archived
1 2 Previous Next 17 Replies Latest reply: May 11, 2011 2:37 PM by TexasApexDeveloper RSS

Change Colour of Row - Oracle APEX SQL Report

691252 Newbie
Currently Being Moderated
I am attempting to change the colour of a single row based upon the value inside of a field in the report.
If the value in the field equals 'n' then I want the row highlighted.

I have created a report and set it to use the Standard Report Template. I then edit the template with the following, but it doesn't seem to work.

Screenshot:
http://img7.imageshack.us/img7/4782/columntemplate.jpg

If I try changing the PL/SQL Express to something I would think would evaluate to true, such as 'n' = 'n' or 1 =1 but still no rows appear in red.

Edited by: apexdev88 on 7/04/2009 19:06
  • 1. Re: Change Colour of Row - Oracle APEX SQL Report
    ATD Guru
    Currently Being Moderated
    Hi,

    There are two reasons why that won't work.

    1 - You have set this as the second Column Template in the report template. Column Template 1 has no condition, is therefore unconditional and, therefore, used for ALL rows in the report. So, swap these two so that your highlighted row is Column Template 1 and your unconditional row is Column Template 2. The final Column Template should be the unconditional one.

    2 - As 'n' is a string, you must match it to a string (you actually do this in your post!). So:
    '#COMPLETED#' = 'n'
    But, bear in mind that this will be case-sensitive, so you may want to do UPPER() or LOWER()?

    Andy
  • 2. Re: Change Colour of Row - Oracle APEX SQL Report
    407853 Newbie
    Currently Being Moderated
    Hi,

    Write your sql with a case statement

    select CASE when 1 = 1 then
    'style="background:#80BFFF">'||column a
    , 'style="background:#80BFFF">'||column B
    ELSE
    columnA, columnB
    END CASE
    from table


    good luck,

    Hugo
  • 3. Re: Change Colour of Row - Oracle APEX SQL Report
    ZKay Journeyer
    Currently Being Moderated
    Hi,

    I am trying to change the background colour of some rows conditionally but I am getting strange result:

    http://apex.oracle.com/pls/otn/f?p=43368:69

    I have made the following changes in the standard template:

    Column Template 1
    <td style="background-color:red;#ALIGNMENT#>#COLUMN_VALUE#</td>

    Column Template 1 Expression
    #DEPTNO# = 10

    Column Template 2
    <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t2data">#COLUMN_VALUE#</td>

    Any idea?

    Thanks,
    Zahid

    Edited by: Zahid Khan on Apr 17, 2009 2:23 PM

    Edited by: Zahid Khan on Apr 17, 2009 2:28 PM
  • 4. Re: Change Colour of Row - Oracle APEX SQL Report
    ATD Guru
    Currently Being Moderated
    Hi Zahid,

    You haven't closed the quotes for the style attribute:
    &lt;td style="background-color:red;" #ALIGNMENT#&gt;#COLUMN_VALUE#&lt;/td&gt;
    Andy
  • 5. Re: Change Colour of Row - Oracle APEX SQL Report
    ZKay Journeyer
    Currently Being Moderated
    Hi Andy,

    Thanks. Its fixed now.

    Two more things:
    1. The alignment of the column values is not correct now.
    2. This change in the Template has affected all the reports based on EMP table. Is there a way to avoid effect on other reports?

    Regards,
    Zahid
  • 6. Re: Change Colour of Row - Oracle APEX SQL Report
    ATD Guru
    Currently Being Moderated
    Hi,

    OK - firstly, when you need to customise a template, you should create a copy of the existing template and then work on that. In Shared Components, Templates, click the Create button and follow the prompts - during this process you will be asked if you want to "start from scratch" or "copy from existing", make sure you select "copy from existing" and, when prompted, select to copy your current report template. Once the new template has been created, you attach this to your report. Then you can apply your conditions. As no other report in your app will be using this template, no other report would be affected by any changes to make to it.

    For the formatting issue, typically, what I would do is copy the Condition 1 template into Condition 2 and then add/remove stuff as required. In your case, if you did that, Condition 1 would start with:
    &lt;td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t2data"&gt;#COLUMN_VALUE#&lt;/td&gt;
    You can then update this to include your styling:
    &lt;td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t2data" style="background-color:red"&gt;#COLUMN_VALUE#&lt;/td&gt;
    Notice that the style attribute is after the class attribute - this should ensure that you overwrite any "background-color" style that may be defined in that class.

    Andy
  • 7. Re: Change Colour of Row - Oracle APEX SQL Report
    ZKay Journeyer
    Currently Being Moderated
    Thanks Andy, it worked fine.

    Zahid
  • 8. Re: Change Colour of Row - Oracle APEX SQL Report
    ATD Guru
    Currently Being Moderated
    You're welcome, Zahid

    Andy
  • 9. Re: Change Colour of Row - Oracle APEX SQL Report
    Tauceef Journeyer
    Currently Being Moderated
    I want to change the background color after checking a column value is NULL or NOT NULL

    so what I am doing is this:

    Column Template1:
    <td style="background-color:pink;"#ALIGNMENT#>#COLUMN_VALUE#</td>

    Condition:
    '#dead#' is not null

    Column Template2:
    <td style="background-color:green;"#ALIGNMENT#>#COLUMN_VALUE#</td>

    Condition:
    '#fallout#' is not null

    Column Template3:
    <td class="t6data"#ALIGNMENT#>#COLUMN_VALUE#</td>


    But all the rows are coming in pink color only.

    Please help me out.

    Thanks.
  • 10. Re: Change Colour of Row - Oracle APEX SQL Report
    Tauceef Journeyer
    Currently Being Moderated
    Please guys its really urgent.
  • 11. Re: Change Colour of Row - Oracle APEX SQL Report
    631222 Expert
    Currently Being Moderated
    Hi,

    #dead#' is not null -- Wrong

    use NVL(#dead#' , '-1') = -1

    Regards,
    Shijesh
  • 12. Re: Change Colour of Row - Oracle APEX SQL Report
    Tauceef Journeyer
    Currently Being Moderated
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Error ERR-1025 Error processing PLSQL expression. nvl('#dead#','-1') = -1
    OK

    it is showing me this error.
  • 13. Re: Change Colour of Row - Oracle APEX SQL Report
    631222 Expert
    Currently Being Moderated
    opps .. typo


    use NVL('#dead#' , -1) = -1
  • 14. Re: Change Colour of Row - Oracle APEX SQL Report
    Tauceef Journeyer
    Currently Being Moderated
    Same error.
    Actually the thing what I understand is that we are using #dead#
    inside single quote which is a character, not actually a NULL
    and second thing we are trying to convert this character into a number, so this error.

    I have already tried NVL function with many different combinations but it is not working.

    Thanks
    Tauceef
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points