Our Objective:
Here I will be outlining how to apply conditional formatting to your grids and reports in oracle apex, for instance shading highly positive figures as green or negative figures as red. This can be especially helpful when creating end user reports.
Lets Begin:
First you will need the report you're applying the formatting to, to have an SQL query as it's source.
Once you have the query you want, we need to add an additional "Conditional_Formatting" column, and for that column to be populated with 'Green' should a certain column's data meet a criteria. Here I have made the 'Conditional_Formatting' column populate with 'Green' when the figure in the 'Likes' column is greater than or equal to 2.
Once you have the query you want, we need to add an additional "Conditional_Formatting" column, and for that column to be populated with 'Green' should a certain column's data meet a criteria. Here I have made the 'Conditional_Formatting' column populate with 'Green' when the figure in the 'Likes' column is greater than or equal to 2.
This will have added an extra column to our report, one which you will probably want to hide from view as it is only used in deciding the color of the conditional formatting.
From here we need to write the HTML expression for the column we want the formatting to be applied to, if you want the whole row to be highlighted you would need to duplicate the HTML expression for each of them, adjusting the column name in the script as you go.
Below is the HTML expression I have used in this example, as you can see it applies a style to the 'LIKES' column, by pulling the value from the 'Conditional_Formatting' column and inserting it into the HTML expression as the 'color' value.
To customize this to your applications needs simply change the html color coding and the sql formula for the "Conditional Formatting" column as required, so if you want negative figures to be shaded red, simply adjust the SQL formula to populate the 'Conditional Formatting" column with the word 'Red' when the require value is less than 0.
I hope this information proves useful to you and let me know of any other aspects of Oracle Apex that could deserve a blog to help explain.
Thank you for reading,
You can read many other useful Oracle EPM Cloud and Netsuite ERP blogs posted by my colleagues at Brovanture here
Richard
Comments
Post a Comment