koolreport icon indicating copy to clipboard operation
koolreport copied to clipboard

Undefined index filtering empty result

Open BernhardK91 opened this issue 6 years ago • 2 comments

Hi there,

I am getting the following error:

Undefined index: DIFFERENZ (View: C:\[...]\resources\views\dashboard\fieldsales.blade.php)

The result of the SQL-query is empty and the problem is occured in the following line:

"dataSource" => $this->dataStore("customer.flop100.annualComparison")->filter('DIFFERENZ', '<', 0),

Thank you in advance!

BernhardK91 avatar Jan 03 '19 13:01 BernhardK91

I solved my problem with this workaround:

if ($this->dataStore("customer.flop100.annualComparison")->count() > 0) {
    Table::create([
        [...]
    ]);
} else {
    echo '<i>no results</i>';
}

BernhardK91 avatar Jan 03 '19 13:01 BernhardK91

That's great. The Table actually detect the empty rows of datastore however the issue lies inside the filter() function which have problem if result is empty. May be it is better to return the datastore itself if there is no data.

koolphp avatar Jan 03 '19 16:01 koolphp