KoolReport's Forum

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

Different format for the column and the footer value #1067

Closed Eugene opened this topic on on Aug 29, 2019 - 5 comments

Eugene commented on Aug 29, 2019

Hi,

Sorry if my topic title is not so clear :-)

I met with the following problem and do not know how to resolve it.

  1. I have a table - the content of one column can be different: I output there input field if I don't have a value in the datastore for it otherwise the value from the datastore - the number.
  2. To output the input field I have to set a type for this column as a string.
  3. To format the values as a number if it is a number I use the formatValue propertie

But what can I do with the sum in the footer? How to format it as a number? See the pic below

This is a part of my Calculated column process:

 "factPayment" => function ($data) {
                    $value = ($data["transfer_date"] === null) ? ($data["AmountCalculated"]) : ($data["paidAmount"]);
                    if ($data["matched"] == 0) {
                        return '<input id="fp_' . $data["invoice_No"] . '" value="' . number_format($value) . '">';
                    } else {
                        return ($data["transfer_date"] === null) ? ($data["AmountCalculated"]) : ($data["paidAmount"]);
                    }
                },

This is a part of my column propertie:

 "factPayment" => array(
                "label" => "Fact",
                "type" => "string",
                "formatValue" => function ($value, $row) {
                    return ($row["matched"] == 0) ? $value : number_format($value);
                },
                "footer" => "sum",
                "cssStyle" => "text-align: right;"

            ),

KoolReport commented on Aug 29, 2019

When the Table formats the value of footer, the $row will not be available, its value will be null, so better you check if the $row is null then you just return the number_format($value). Hope that it helps.

Eugene commented on Aug 29, 2019

Thank you ... so easy.. :-))

KoolReport commented on Aug 29, 2019

Awesome :)

P.s: Only reading your tittle, I know the issue.

Eugene commented on Aug 29, 2019

:-) so my message is too long :-) I can make it more shot...

KoolReport commented on Aug 29, 2019

Please don't :)) , chance that we known issue by reading title are rare :D, consider I am lucky today.

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
solved

None