KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Non - Repeat Column Footer #1048

Open Michael Ikhane opened this topic on on Aug 18, 2019 - 9 comments

Michael Ikhane commented on Aug 18, 2019

Hi,

The Count aggregation for column footer doesn't work. I found a way around it.

But my issue is that when I export to pdf using CloudExport, the column footer repeats on every page. So instead of getting the Grand total at the end of the table, it is displayed at the end of each page. How can I make the footer to NOT-repeat.

David Winterburn commented on Aug 19, 2019

Hi Michael,

Please try this cloud export option:

->pdf([
    ...
    "noRepeatTableFooter" => true
])

Let us know if it works for you. Thanks!

Michael Ikhane commented on Aug 19, 2019

Thanks David,

When I used that option, the footer didn't repeat, but it was moved the footer from the bottom to the top of the table. I need to have it at the bottom.

Cheers

David Winterburn commented on Aug 19, 2019

Hi Michael,

I think this is because at the moment in the Table widget, the tfoot part lies before tbody so it could work when "showFooter" => "top". An unintended consequence is if we stop repeating tfoot it will be shown just before tbody. For now to fix this please open the file koolreport/core/src/widgets/koolphp/Table.tpl.php and move the tfoot part to after tbody:

    <?php
        if ($this->showFooter!==null) {
        ?>
        <tfoot <?php echo ($this->showFooter==="top")?"style='display:table-row-group'":""; ?>>
            <tr>
            <?php
            foreach ($showColumnKeys as $cKey) {
                $cssStyle = Utility::get($meta["columns"][$cKey], "cssStyle", null);
                $tfStyle = is_string($cssStyle)?$cssStyle:Utility::get($cssStyle, "tf");
            ?>
                <td <?php if($tfClass){echo " class='".((gettype($tfClass)=="string")?$tfClass:$tfClass($cKey))."'";} ?> <?php echo ($tfStyle)?"style='$tfStyle'":""; ?> >
                    <?php 
                        $footerValue = "";
                        $method = strtolower(Utility::get($meta["columns"][$cKey], "footer"));
                        if( in_array($method, array("count","sum","avg","min","max","mode")) ) {
                            $footerValue = Table::formatValue($this->dataStore->$method($cKey), $meta["columns"][$cKey]);
                        }
                        $footerText = Utility::get($meta["columns"][$cKey],"footerText");
                        if ($footerText!==null) {
                            echo str_replace("@value", $footerValue, $footerText);
                        } else {
                            echo $footerValue;
                        }
                    ?>
                </td>	
            <?php	
            }
            ?>
            </tr>
        </tfoot>
        <?php	
        }
        ?>

Hope this works for you. We will find a compatible solution for this the Table widget footer in the next release. Thanks!

Michael Ikhane commented on Aug 19, 2019

Hello David,

It worked. Thank you.

One more thing please, I would like to force a page break at the beginning of each row group header.

David Winterburn commented on Aug 19, 2019

Hi Michael,

Not sure if this would work for a table row group header element but in cloud export service we have these two css classes: break-before and break-after. When you add either of these to an element in your page, a page break would appear just before or after the element. Thanks!

Michael Ikhane commented on Aug 19, 2019

Hi,

Is this the correct usage:

"grouping" => [
        "complaint_type" => [
                "calculate" => [
                         "{countPlaintType}" => ["count","complaint_id"]
                  ],
                  "top" => "<div class=\"break-before\">{complaint_type}</div>",
          ]
  ],
KoolReport commented on Aug 19, 2019

There is no need to count complaint type, there is pre-defined {count} variable that you can put to "top". Here is the documentation.

Michael Ikhane commented on Aug 19, 2019

Thanks. I am only 6days old with KoolReport :-)

What about the page break, that I did above didn't work.

David Winterburn commented on Aug 20, 2019

Hi Michael,

This page break inside pdf printed table took me all today but here's a solution for you to try. In your pdf view file please set your Table widget name/id and grouping like this:

            Table::create(array(
                "name" => 'myTable',
                ...
                "grouping" => [
                  "complaint_type" => [
                      "top" => "{complaint_type}",
                ] 
                ...                

Then add the following css, html and javascript to anywhere in the file:

    <style>
        @media  print {
          #myTable .break-row td {
            padding: 0 !important;
          }
    }}
    </style>
          <table id='tempTable' style='display:none'>
              <tr class='break-row'><td colspan='999'><div></div><div style='page-break-before: always'></div></td></tr>
          </table>
          <script>
            KoolReport.load.onDone(function() {
              var breakRow = document.querySelector('#tempTable tr');
              var tbody = document.querySelector('#myTable tbody');
              var rows = document.querySelectorAll('#myTable tr.row-group');
              for (var i=1; i<rows.length; i+=1) {
                tbody.insertBefore(breakRow.cloneNode(true), rows[i]);
              }
            });
          </script> 

Let us know if this works for you. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None