KoolReport's Forum

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

Pivot customization #758

Open Rafa opened this topic on on Mar 21, 2019 - 6 comments

Rafa commented on Mar 21, 2019

Hi, how are you guys?

I'm using the PivotTable-Bun template for PivotTable and I trying to configure some parts. First: how can I put the "total" row on the end of my report? I do not know why, the total only appears in the end if I use the default PivotTable template. Second quesiton: how can I create a row without the "plus" and "minus" square? It's a row that represents my report opening balance and I need to remove the square and put that row before the total row.

Take a look here:

How can I achieve this?

Thank you so much!

Best regards,

David Winterburn commented on Mar 22, 2019

Hi Rafa,

To push the grand total row to the end of PivotTable-Bun template, please open the file pivot/PivotUtil.php, go to line:

$this->sort($rowIndexes2, $rowSortInfo);

and insert these right after it:

$grandTotalIndex = array_shift($rowIndexes2);
array_push($rowIndexes2, $grandTotalIndex);

On the other issue, to hide certain plus or minus icons, please add the following css rule to your page:

    [data-row-field="0"] > .fa {
      display: none;
    }

Depending on your data-row-field, this will hide the first level icons (row-field=0) or the second level icons (row-field=1), etc.

Let us know if these methods work for you. Thanks!

Rafa commented on Mar 22, 2019

Hi,

First of all, thank you so much. It worked.

It is just missing a item of my question: How can I put my opening balance before "total". Can I control the rows sort?

Best regards!

David Winterburn commented on Mar 25, 2019

Hi Rafa,

Didn't the edit of code push the Total row to the end of page? What do you mean by "my opening balance before "total"? Do you care to provide screenshot to specifically describe what you want. Thanks!

Rafa commented on Mar 25, 2019

Hi, let me better explain.

In the following print you will see three rows. I marked the problems with numbers 1 and 2. The number 1 was resolved with your solution to put the total row to the end of page. But the number 2 is another problem. I need to put that row "SALDO INICIAL" before "TOTAL" row, I need to know how can I define the order of my rows. Take a look:

How can I achieve this?

Thank you so much!

Best regards,

David Winterburn commented on Mar 26, 2019

Hi Rafa,

Both PivotTable and PivotMatrix have "rowSort" and "columnSort" properties. In your case, perhaps this could be useful:

        PivotTable::create(array(
            ...
            'rowSort' => array(
              'balanceField' => function($a, $b) {
                if ($a === "SALDO INICIAL") return -1;
                if ($b === "SALDO INICIAL") return 1;
                return strcmp($a, $b);
              },
            ),
            ...
        ));

You might want to change "balanceField" to the field that your balance belongs to and experiment with swapping -1, 1 in the above code to see its effect. Thanks!

Rafa commented on Mar 28, 2019

Perfect, thank you!

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

Pivot