KoolReport's Forum

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

Drill Down is Re rendering the whole page and putting that where my chart should be. #2894

Open iWorQ Systems opened this topic on on Dec 2, 2022 - 5 comments

iWorQ Systems commented on Dec 2, 2022

I am trying to use a drill down and have been running into a weird issue. whenever I click on the chart the first time all it does is post the page again where the chart should be. Here is a picture for a reference.

Here is my code for the drill down:

DrillDown::create([
            "name"=>"saleDrillDown",
            "title"=>"Fee Report",
            "levels"=>[
                [
                    "title"=>"feename",
                    "content"=>function()
                    {
                        ColumnChart::create([
                            "dataSource"=> $this->dataStore("graphResults"),
                            "columns"=>[
                                "feename"=>[
                                    "type"=>"string",
                                    "label"=>"Fee Name",
                                ],
                                "amount"=>[
                                    "label"=>"Amount",
                                    "prefix"=>"$",
                                ]
                                ],
                            "clientEvents"=>[
                                "itemSelect"=>"function(params){
                                    saleDrillDown.next({feename:params.selectedRow[0]});
                                }",
                            ]
                        ]);
                    }
                ],
                [
                    "title"=>function($params,$scope)
                    {
                        return "feename ".$params["feename"];
                    },
                    "content"=>function($params,$scope)
                    {
                        PieChart::create([
//I removed the query here. I know that this is not the issue. 
                            "dataSource"=>(graphList2
                                ")
                                ->params([
                                    ":aid" => $_GET['aid'],
                                    ":fid" => $_GET['fid'],
                                    ":aid2" => $_GET['aid'],
                                    ":fid2" => $_GET['fid'],
                                    ":aid3" => $_GET['aid'],
                                    ":fid3" => $_GET['fid'],
                                    ":date1" => $this->params['date1'],
                                    ":date2" => $this->params['date2'],
                                    ":feename"=>$params["feename"],
                                ])
                            )
                            ,
                            "columns"=>[
                                "Permit Type"=>[
                                    "type"=>"string",
                                ],
                                "amount"=>[
                                    "label"=>"Amount",
                                    "prefix"=>"$",
                                ]
                                ],
                        ]);
                    }        
                ],

            ],
        ]);

I really do not know why this is happening or where it is being caused. I know that the next function is where it starts, but no idea where to go from there. Any help would be appreciated! Thank you.

KoolReport commented on Dec 5, 2022

During the post back ajax of DrillDown, the parameters date1 and date2 is not available. You need to store those parameter inside "scope" of drilldown like this:

DrillDown::create([
    "scope"=>[
        "date1"=>$this->params['date1'],
        "date2"=>$this->params['date2'],
    ]
])

Inside the content of second level, you access the date1 and date2 via $scope like this:

"content"=>function($params,$scope)
{
    ...
    ":date1"=>$scope["date1"],
    ":date2"=>$scope["date2"]
    ...
}
iWorQ Systems commented on Dec 5, 2022

That did not seem to change anything.

Still does the same thing. I thought maybe it was because the drill down was in a subreport, but that did not seem to change anything.

iWorQ Systems commented on Dec 5, 2022

I am using JS charts, is that going to be a problem?

KoolReport commented on Dec 6, 2022

Could you please post us your code. Or you can send to our support email if you want to be private.

iWorQ Systems commented on Dec 8, 2022

Just decided to go with Manual Drill downs instead. Got that working for some reason.

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
help needed

DrillDown