KoolReport's Forum

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

Table removeDuplicate issue #1466

Closed Alex Chartier opened this topic on on May 31, 2020 - 9 comments

Alex Chartier commented on May 31, 2020

I am outputting a table and have removeDuplicate on the first two columns. What I would like is that whenever the value of the first column changes that the value in the second column is always displayed. Right now the removeDuplicate is removing all the values of the second column until it changes. Please see the image below:

What I would like to see is that beside the date 2020-05-16 the time of 07:30:00 is shown. How can I do this?

Thanks.

KoolReport commented on May 31, 2020

May I see your Table code?

Alex Chartier commented on May 31, 2020

Here is my table create:

    Table::create([
        "dataStore"=>$this->dataStore('Direct'),
		"columns"=>$this->buildColumns(),
        "removeDuplicate" => ["startdate", "starttime"],
        "cssClass"=>["table" =>"table table bordered table-striped", "th" => ""],
        ],
    );

And the buildColumns function creates this array:

Array
(
    [startdate] => Array
        (
            [label] => Date
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;width:100px;vertical-align:top;
                    [th] => text-align:left
                )
        )
    [starttime] => Array
        (
            [label] => Start Time
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;;width:100px;vertical-align:top;
                    [th] => text-align:left
                )
        )
    [name] => Array
        (
            [label] => Name
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;;width:200px;
                    [th] => text-align:left
                )
        )
    [email] => Array
        (
            [label] => E-Mail
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;;width:325px;
                    [th] => text-align:left
                )
        )
    [phone] => Array
        (
            [label] => Phone
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;;width:125px;
                    [th] => text-align:left
                )
        )
    [address] => Array
        (
            [label] => Address
            [cssStyle] => Array
                (
                    [td] => padding-top:4px;padding-bottom:4px;
                    [th] => text-align:left
                )
        )
)
Alex Chartier commented on May 31, 2020

Note: The text values in the above array are all quoted properly. I just dumped the array with print_r which strips them.

Alex Chartier commented on Jun 6, 2020

Any update on this? Thanks.

Alex Chartier commented on Jun 19, 2020

Still looking for an update....

Alex Chartier commented on Jul 6, 2020

Still waiting for an update.

Alex Chartier commented on Dec 12, 2020

Still waiting for an update.

Sebastian Morales commented on Dec 14, 2020

Alex, it seems the "removeDuplicate" option works for each column independently. However, there's a workaround to make it work across columns by concatenating several columns together. And then use a column's "formatValue" option to show its self value only:

    //MyReport.php
    ...
    ->pipe(new \koolreport\processes\Map(array(
        "{value}" => function($row) {
            $row["starttime"] = $row["startdate"] . "||" . $row["starttime"]; //concatenate the date and time columns together
            return $row;
        }
    )))


    //MyReport.view.php
    $columns = $this->buildColumns();
    $columns["starttime"]["formatValue"] = function($value, $row, $cKey) {
        $timePart = explode("||", $value)[1];
        return $timePart;
    }
    Table::create([
        "dataStore"=>$this->dataStore('Direct'),
        "columns"=>$columns,
        "removeDuplicate" => ["startdate", "starttime"],
        "cssClass"=>["table" =>"table table bordered table-striped", "th" => ""],
        ],
    );            

Pls try it and let us know if there's any problem. Cheers,

Alex Chartier commented on Dec 14, 2020

Hello Sabastian, yes, it works. I had to remove the $cKey argument as the call generated an exception for too many parameters.

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
bug

None