KoolReport's Forum

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

Koolreport throw out "error" when datastore is empty #2009

Open Frank Sun opened this topic on on Apr 2, 2021 - 5 comments

Frank Sun commented on Apr 2, 2021

Hi,

I use koolreport with laravel, and I build a pivot table. The report is working fine when data exists in the selected period. But if there is no data in selected period, seems a error message 'error' is throw out.
When debuging, I try to output the datastore('period') which I used for select, it is empty. I'm quite sure it should contain data.

I cannot find any error message in laravel log. Is there anyway to debug?

Thanks.

Frank Sun commented on Apr 2, 2021

I have another report, when there is no data, the header is working fine.

Frank Sun commented on Apr 2, 2021

To make the question more clear,

First, I pipe $data_consignment to $node2. Then I pipe $node2 to pivot, if the $node2 is empty, the error come out.

Is there anyway to avoid this error. Or is there any method to check whether $node2 is empty before pipe to pivot?

    $data_consignment
    ->pipe(new Map(array(
        '{value}' => function($row, $metaData) {
        # ... Coding ...
        },
        '{meta}' => function($metaData) {
        # ... Coding ...
        },
    )))
    ->saveTo($node2);

    $node2->pipe(new Pivot(array(
        "dimensions"=>array(
            "row" => "0_x51, 0_x22, 0_x61",
            "column" => "0_x23",
        ),
        "aggregates"=>array(
            "sum"=>"0_x07, 0_x32",
        )
    )))
    ->pipe($this->dataStore("consignment"));
Sebastian Morales commented on Apr 5, 2021

Hi Frank, would you pls post the full error message and stack trace when data pipe is empty? Tks,

Frank Sun commented on Apr 9, 2021

In log file, I cannot find any error message. Seem everything runs smoothly, but the output is a string "error".

I use a workaround, use a sql query to check the data first, then pipe to Pivot. I'm quite sure there is something wrong in :

$node2->pipe(new Pivot(array(
    "dimensions"=>array(
        "row" => "0_x51, 0_x22, 0_x61",
        "column" => "0_x23",
    ),
    "aggregates"=>array(
        "sum"=>"0_x07, 0_x32",
    )
)))
->pipe($this->dataStore("consignment"));

Hope there is an elegant way to do it.

Sebastian Morales commented on Apr 9, 2021

We have tested it and can confirm that empty data doesn't cause any error in the Pivot process or the PivotTable widget. I would suggest remove parts of your code till you find down which one outputed the error string. Tks,

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