Forum Stats

  • 3,853,698 Users
  • 2,264,256 Discussions
  • 7,905,434 Comments

Discussions

How to change the background color of oracle apex classic report on based on condition

Pankaj Kumar Mandal
Pankaj Kumar Mandal Member Posts: 59
edited Apr 29, 2014 4:35AM in APEX Discussions

I am working oracle apex 4.2 environment, where I am developing report, in which I wan to implement the color of row should change according to column value.

For example I was working with below query

select

case

when sal > 1000 then

'<span style=background-color:red>'

else

'<span style=background-color:green>'

end,

"EMPNO",

"ENAME",

"JOB",

"MGR",

"HIREDATE",

"SAL",

"COMM",

"DEPTNO"

from EMP

But it was not able to change the color of the row. Please guide me.

Tagged:
«1

Answers

  • Sunil Bhatia
    Sunil Bhatia Member Posts: 1,280 Bronze Trophy

    Hi Pankaj,

    Atleast search forum once before posting question. Exactly same requirement with "Jari" correct answer

    You can extend this to specific row, etc

    Thanks

    Sunil Bhatia

  • I already check it and it was not meeting my requirement thats why I posted the question in forum, In my case as the query is dynamically generated from function. so how to mentioned the column name SAL in javascript.

    <script type="text/javascript"><br/>$(function(){<br/> $('##REGION_ID# input[name="f01"]').each(function(i){<br/>  $(this).parents("tr:first").find('[headers="SAL"]').css({"background-color":$v(this)});<br/> });<br/>});<br/></script>

  • Sunil Bhatia
    Sunil Bhatia Member Posts: 1,280 Bronze Trophy

    Hi Pankaj,

    In original question, you mentioned

    I was working with below query

    select

    case

    when sal > 1000 then

    '<span style=background-color:red>'

    else

    '<span style=background-color:green>'

    end,

    "EMPNO",

    "ENAME",

    "JOB",

    "MGR",

    "HIREDATE",

    "SAL",

    "COMM",

    "DEPTNO"

    from EMP

    Nowhere it signifies, you are generating it from function? Did it?

    And if you read it correctly, jquery can be handled by using classes.

    You can write a specific class in the span which is generated by your function. And on load of page, that span class can carry background color.

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,217 Red Diamond
    edited Apr 25, 2014 5:00AM
    Pankaj Kumar Mandal wrote:
    
    I already check it and it was not meeting my requirement thats why I posted the question in forum, In my case as the query is dynamically generated from function. so how to mentioned the column name SAL in javascript.
    
    

    How is the query "dynamically generated"? What is dynamic: Projection? Source? Predicates? All of them?

    What is the logic that determines the colour change?

  • @Sunil Bhatia

    Yeah I missed that out and surely I will try out the your suggestion and let you know if it worked out or not.

  • Hi,

    I have developimg a centralized system for reporting purpose where I am putting a query in table from where I am passing some parameter which is stored in a table.

    The final thing is I have created single report region for the same in the source there is  function which takes report_id as parameter and returning that query depending on the report name selected in LOV, therefore  the report column and data changes according to the query.

    For color changing I am storing the condition in a table with respect to report_id and in the function which is returning query I am checking condition and modifying the original query

    For e.g. my original query is which is stored in query table

    as

    ID             Query

    1              select "EMPNO",  "ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO" from EMP

    and my condition is store in condition as below:

    report_id      condition      color

    1                SAL>1000      red

    1                 default           green

    In query returning function, it checks for the condition and return the below query

    select

    case

    when sal > 1000 then

    '<span style=background-color:red>'

    else

    '<span style=background-color:green>'

    end,

    "EMPNO",

    "ENAME",

    "JOB",

    "MGR",

    "HIREDATE",

    "SAL",

    "COMM",

    "DEPTNO"

    from EMP

    This is the whole logic in the application

  • fac586
    fac586 Senior Technical Architect Member Posts: 21,217 Red Diamond
    Pankaj Kumar Mandal wrote:
    
     
    For color changing I am storing the condition in a table with respect to report_id and in the function which is returning query I am checking condition and modifying the original query
    
    For e.g. my original query is which is stored in query table
    as
    
    ID             Query
    1              select "EMPNO",  "ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO" from EMP
    
    and my condition is store in condition as below:
    
    report_id      condition      color
    1                SAL>1000      red
    1                 default           green
    
    
    In query returning function, it checks for the condition and return the below query
    
    select
    case
    when sal > 1000 then
    '<span style=background-color:red>'
    else
    '<span style=background-color:green>'
    end,
    "EMPNO",
    "ENAME",
    "JOB",
    "MGR",
    "HIREDATE",
    "SAL",
    "COMM",
    "DEPTNO"
    from EMP
    This is the whole logic in the application
    

    Can there be more than one condition and a default for each report?

  • Yes there can be more than one condition and also there will be a default value for each report.

  • GhanaApexDeveloper
    GhanaApexDeveloper Member Posts: 467 Silver Badge

    Hi Pankaj,

    please check this thread

    https://community.oracle.com/thread/3551474

    Thanks

    Benjamin

  • Hi,

    I implemented and converted the column to STANDARD but it is not work that way also.

This discussion has been closed.