6 Replies Latest reply on Feb 5, 2013 5:15 PM by Howard (... in Training)

    Classic report - Highlight row

      APEX 4.2.1

      With all the latest and greatest dynamic action and jQuery goodness in 4.2.1, what is the easiest, declarative way to highlight rows in a classic report region (Generic Column Template) based on data condition using values on the row, using #COL# notation? e.g. If SAL > 1000 and DEPT = Marketing, highlight row in red or some such.

      In prior versions, this involved copying the Generic Column Template to one used just by this report and use the (up to 4) Column Templates with a PL/SQL expression.

        • 1. Re: Classic report - Highlight row
          Andreas Wismann
          Custom report templates are okay if your needs are straightforward. But you said it already, there are only four different flavors to chose from.

          Here is a solution that'll work on all pages if once installed and can be extended to a multitude of visual attributes. Only an example that you may want to adapt to your liking.

          Edit Page, "CSS, Inline", or via Shared Components > CSS files
          td.color1 {background-color:#9F9} /* Table cell gets colored in light green  */
          td.color2 {background-color:#FF9} /* Table cell gets colored in light yellow */
          td.color3 {background-color:#F99} /* Table cell gets colored in light red    */
          /** and so forth, followed by as many declarations as you need... */
          Page Template, "Function and Global Variable Declaration":
          /** Change the visual appearance of your classic report as you like after it's rendered */
          function customClassicReportDisplay(){
            /** Transfer the color class from the text to the table cell */
            $('td span.color1').closest('td').addClass('color1');
            $('td span.color2').closest('td').addClass('color2');
            $('td span.color3').closest('td').addClass('color3');
            // and so forth, followed by as many declarations as you need...
          This jQuery code can be simplified, especially the handling of many lines for many colors can still be compacted, which makes it more difficult to understand though.

          Page Template, "Execute when Page Loads":
          /** Perform the function on Page Load */
          /** Perform the function after Partial Page Rendering */
          $('form').bind('apexafterrefresh', function(){
          Here comes the trick. In the SQL statement, you wrap a <span> HTML tag with a different class declaration around each value that you want to color.
          SELECT '<span class="color' || case when some_value > 100 then '2' else null end || '">' || some_value       || '</span>' AS some_value
               , '<span class="color' || decode(some_other_value, 'too much', '3', NULL)   || '">' || some_other_value || '</span>' AS some_other_value
               , '<span class="color' || case when last_value between  0 and  10 then '1'
                                              when last_value between 11 and  50 then '2'
                                              when last_value between 51 and 100 then '3'
                                              else null end                                || '">' || last_value       || '</span>' AS last_value
            FROM ...
          This obviously makes the SQL a bit more complicated but in my opinion, I think this is a data driven topic and therefore just fine. Hence you say "depending on value ranges I want to change something" - and that belongs to SQL. WHAT you want to do (here: change color) is then up to your JS and CSS declaration. If you shift the SQL code into a view it's better to maintain and won't get spoiled by non-savvy third party developers...

          I know that's not what you originally asked for, because there is no #COL# notation, but for me it's the most flexible solution I can think of under APEX.
          1 person found this helpful
          • 2. Re: Classic report - Highlight row
            Hm, thanks. This is too much work. :-) APEX has spoiled us with easy, declarative solutions.

            Feature request - APEX should add a section to Report Attributes to specify a PL/SQL expression using #COL# substitutions and a CSS/JS hook into the current report row (this.currentRow or some such) so we can style the current row/cell as needed.
            • 3. Re: Classic report - Highlight row
              Andreas Wismann
              Where can I sign? :-)
              • 4. Re: Classic report - Highlight row
                Howard (... in Training)
                At one time there was an active enhancement thread Enhancement Request Thread : Post 3.1 but it's last entry is from 2010. Maybe the forum tells you where to make enhancement / feature requests but I don't see any reference o such. I hope the new forum identifies this prominently. Ah, could that be a new feature?

                • 5. Re: Classic report - Highlight row
                  https://apex.oracle.com/pls/apex/f?p=55447:1 appears to be the official Oracle sanctioned feature request board. Logged this request there.
                  • 6. Re: Classic report - Highlight row
                    Howard (... in Training)
                    Yes. I just found the reference myself. Thanks.