KoolReport's Forum

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

DrillDown KWidget Parameter Error #3179

Closed afieq opened this topic on on Oct 23, 2023 - 2 comments

afieq commented on Oct 23, 2023

Hi,

I encounter a problem where i created a Drilldown on my Dashboard. The error occur where i created a filter on my dashboard and i want to pass the parameter chosen by the filter and pass into my DrillDown report. I have tested the DrillDown without the parameter, it runs perfectly normal but when i tried include the filter parameter "Agency Name" it's just kept on loading endlessly. Is there a solution for my problem?

$range = $this->sibling("AgencyNameLookup")->value();
return [
Level::create()
                ->title("Agency ".$range)
                ->widget(
                    KWidget::create()
                    ->use(\koolreport\widgets\google\ColumnChart::class)
                    ->dataSource(function($params, $scope){
                        return MyTable::rawSQL(
                            str_replace(":AgencyName",$range,"
                            ..//my mysql statement
                            where agency.name = :AgencyName
                            ..//my mysql statement
                    "//)
                    )->run();
                    })->columns([
                        "Year"=>["type"=>"string"],
                        "Amount"=>[
                            "type"=>"number",
                            "prefix"=>'$
                        ]
                    ])
                    ->settings([
                        "colorScheme"=>ColorList::random()
                    ])
                ),
];

Thanks in advance.

Regards, Afieq

Sebastian Morales commented on Oct 23, 2023

You probably need to pass the $range variable to the anonymous function function($params, $scope) like this:

                    ->dataSource(function($params, $scope) use ($range) {
                        ...

Otherwise, in that function $range is not defined at all.

afieq commented on Oct 24, 2023

Hi Sebastian,

Based on your guidance, my DriilDown report now works like a charm. No wonder my report does not works after many attempt on solving the passing parameter myself. Thanks again for your help in solving my issue.

Regards, Afieq

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

DrillDown