KoolReport's Forum

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

Concatenation of Integers and formatting not working for new copyColumn #2485

Closed hsw opened this topic on on Dec 8, 2021 - 1 comments

hsw commented on Dec 8, 2021

Hi,

I already have a working report consisting of data table. Then I added 2 new columns "Rates" and "Instalments" using copyColumn. Y1 Rate and Y2 Rate (both are string type) are concatenated with "<br/>" and output to "Rates" column using custom function. And Y1 Instalment and Y2 Instalment (both are integers) are concatenated and output to Instalments column using custom function as well.

Below is the output I got. The column in question is "Instalments" as the output fails display.

Below are the sample codes... `

    ->pipe(new CalculatedColumn(array(
        "Y1 Instalment"=>"....",
        "Y2 Instalment"=>"....",
        )))

    ->pipe(new CopyColumn(array(
        "Rates"=>"Y1 Rate",
        "Instalments"=>"Y1 Instalment"
        )))

    ->pipe(new Custom(function($row){
        $row["Rates"] = $row["Rates"]."<br/>".$row["Y2 Rate"];
        
        $row["Instalments"] = "$" . number_format($row["Instalments"], 2) . "/mth<br/>$" . number_format($row["Y2 Instalment"], 2) . "/mth";
        return $row; 
    }))

hsw commented on Dec 10, 2021

Hi,

I tried to code in another way, and then I can get concatenate the Y1 and Y2 instalments into the "Instalments" column to output correctly. However, the "Y1 Instalment" and "Y2 Instalment" columns become blank. Not important, I can hide these columns. Don't understand why sometimes this happens. But the report is correct. So, will just close the issue.

    ->pipe(new CalculatedColumn(array(
        "Y1 Instalment"=>"....",
        "Y2 Instalment"=>"....",
        )))

    ->pipe(new CopyColumn(array(
        "Rates"=>"Y1 Rate",
        "Instalments"=>""
        )))

    ->pipe(new Custom(function($row){
        $row["Rates"] = $row["Rates"]."<br/>".$row["Y2 Rate"];
        $row["Y1 Instalment"] = "$" . number_format($row["Instalments"], 2) . "/mth";
        $row["Y2 Instalment"] = "$" . number_format($row["Instalments"], 2) . "/mth";
        $row["Instalments"] = $row["Y1 Instalment"] . "<br/>" . $row["Y2 Instalment"]; 
    }))

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