1 2 Previous Next 21 Replies Latest reply on Mar 22, 2012 1:54 PM by fac586 Go to original post
      • 15. Re: Alternating row color ordered by value
        859228
        Hello Paul

        I took a look at the links. They deal with background coloring. So it's possible... somehow.
        I built a new page doing exactly as said in the links. But it still not works. Maybe because this is an explanation for an older APEX version.

        At least I found out, how to color all rows.
        In my template I have
        <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="t1data" style="background-color:#BG_COLOUR#">#COLUMN_VALUE#</td> 
        The column *#BG_COLOUR#* has values to color the rows with (e.g.. *#FFFFFF* and *#BFBFBF* )
        When I replace the *:#BG_COLOUR#* with green it works and all the rows of the report get green. (At least until I hover over them with my mouse, then they are white again :( )

        So why isn't it working with the *#BG_COLOUR#* tag. I also read the explanation at docs.oracle.com, and I think it's supposed to work.

        My querry looks like this
        select b.id,
               b.company_name,
               b.country,
               case
                   when mod(n.num, 2) = 0
                   then '#FFFFFF'
                   else '#BFBFBF'
               end bg_colour,
               ...
        from ...
        Regards
        Felix
        • 17. Re: Alternating row color ordered by value
          fac586
          Please reproduce the problem on apex.oracle.com and post guest developer credentials so we can have a look.
          • 18. Re: Alternating row color ordered by value
            859228
            Hello Paul

            I requested a new Workspace an reproduced my problem.

            http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
            Workspace: FELIXROWCOLOR
            Username: GUEST
            Password: Help123

            The report is on Page 1 and has a hidden column BG_COLOUR.
            A copy of the standard Template was made (Standard with row coloring) with a little enhancement an the Row Template:
            <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="data" style="background-color:#BG_COLOUR#">#COLUMN_VALUE#</td>
            The background color should be read out from the column BG_COLOUR .

            The data of the report I took from the OEHR Sample Objects.

            Regards

            Felix
            • 19. Re: Alternating row color ordered by value
              fac586
              Felix wrote:

              The report is on Page 1 and has a hidden column BG_COLOUR.
              A copy of the standard Template was made (Standard with row coloring) with a little enhancement an the Row Template:
              The method on the linked thread requires that a Named Column (row template) report template be used. A copy of the Standard template is a Generic Columns (column template).

              It is actually possible to do this using either template type, as I've demonstrated in your workspace. To match the appearance of the theme in a new Named Column template it's necessary to copy bits of the standard report template definition into the corresponding parts of the new template. (Most themes don't come with an existing Named Column template you can copy from.)
              <td#ALIGNMENT# headers="#COLUMN_HEADER_NAME#" class="data" style="background-color:#BG_COLOUR#">#COLUMN_VALUE#</td>
              The background color should be read out from the column BG_COLOUR .
              Rather than specifying colours directly in the query/template HTML a better approach is to use a class name and specify the actual colours in separate CSS. This results in simpler, smaller templates and generated HTML.

              For a named column template I followed the instructions linked to above, creating a new "Customers by Country" named column template, with a Before Rows definition copied from the theme Standard report&mdash;plus a custom class&mdash;and the column headers required by the report:
              <table cellpadding="0" border="0" cellspacing="0" summary="" #REPORT_ATTRIBUTES# id="report_#REGION_STATIC_ID#">
                #TOP_PAGINATION#
                <tr>
                  <td>
                    <table cellpadding="0" border="0" cellspacing="0" summary="" class="report-standard customer-by-country">
                      <tr>
                        <th class="header">#1#</th>
                        <th class="header">#2#</th>
                        <th class="header">#3#</th>
                        <th class="header">#4#</th>
                      </tr>
              Row Template 1 defined as:
              <tr class="#ROW_CLASS#">
                <td>#CUSTOMER_ID#</td>
                <td>#CUST_FIRST_NAME#</td>
                <td>#CUST_LAST_NAME#</td>
                <td>#COUNTRY#</td>
              </tr>
              The report query was then modified to:
              select c.customer_id, 
                     c.cust_first_name,
                     c.cust_last_name,
                     n.country,
                     case
                         when mod(n.num,2) = 1
                         then 'data'
                         else 'dataalt'
                     end row_class
              ...
              Note that the Show column attribute must be checked for the <tt>ROW_CLASS</tt> column: this is required for any columns that are emitted somewhere in the template HTML, even if they are not actually visible to the user.

              And an embedded style sheet added to the page HTML Header:
              <style type="text/css">
              .customer-by-country td {
                border-bottom: 1px solid #AAAAAA;
                padding: 4px 10px;
              }
              .customer-by-country tr.data td {
                background-color: #ffffff;
              }
              .customer-by-country tr.dataalt td {
                background-color: #bfbfbf;
              }
              </style>
              Using the other approach I created a "Standard, Alternating Row Colors from ALT column" custom Generic Columns template as a copy of the "Standard, Alternating Row Colors" template. The only modification here is to change the Column Template 1 Condition to Use Based on PL/SQL Expression, and Column Temlpate 1 Expression to
              #ALT# = '1'
              Then modify the query to:
              select c.customer_id,
                     c.cust_first_name,
                     c.cust_last_name,
                     n.country,
                     mod(n.num,2) alt
              ...
              The second, Generic Columns template is probably better here as it's simpler to set up, more flexible, and reuses the existing theme CSS. This template can be reused for any report that can generate an <tt>ALT</tt> column that switches between '1' and some other value. The Named Column template can only be used by reports that return 5 columns with those names.
              • 20. Re: Alternating row color ordered by value
                859228
                Hello Paul

                I tried the first possibility. It works perfectly. Then I discovered, that the second posibillity is much shorter.

                Thanks for help

                Felix
                • 21. Re: Alternating row color ordered by value
                  fac586
                  Felix wrote:

                  I tried the first possibility. It works perfectly. Then I discovered, that the second posibillity is much shorter.
                  I did say that. Still it's useful practice on working with custom report templates, the possibilities of which are endless...
                  1 2 Previous Next