KoolReport's Forum

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

Help with DrillDown #625

Open Batouta opened this topic on on Jan 28, 2019 - 6 comments

Batouta commented on Jan 28, 2019

I did an example with the drilldown, but when I click on the master, nothing is displayed. Please see my code.

DrillDown::create(array(
        "name"=>"BeneficiaireLocalite",
        "title"=>"Bénéficiaire par localite",
        "levels"=>array(
            array(
                "title"=>"Toutes regions",
                "content"=>function($params,$scope)
                {
                    ColumnChart::create(array(
                        "dataSource"=>(
                            $this->src("test")->query("
                        SELECT r.nomreg region,count(*) as nombre
                        FROM region r, beneficiaire b
						where r.idreg=b.idreg
                        GROUP BY region
                            ")
                        ),
                        "clientEvents"=>array(
                            "itemSelect"=>"function(params){
                                BeneficiaireLocalite.next({region:params.selectedRow[0]});
                            }",
                        )
                    ));
                }
            ),
            array(
                "title"=>function($params,$scope)
                {
                    return "Region ".$params["region"];
                },
                "content"=>function($params,$scope)
                {
                    ColumnChart::create(array(
                        "dataSource"=>(
                            $this->src("test")->query("
                        SELECT p.nompref prefecture, count(*) as nombre
                        FROM beneficiaire b join prefecture p on b.idpref=p.idpref
						join region r on p.idreg=r.idreg 
                        WHERE  r.nomreg=:region
                        GROUP BY prefecture
                            ")
                            ->params(array(
                                ":region"=>$params["region"]
                            ))
                        )
                        ,
                    ));
                }        
            ),
        ),
));
KoolReport commented on Jan 28, 2019

Your code seems perfect, I think problem may be in the second query. Could you please test it seperatedly, for example, you take a region value and input directly to the query and run it in phpmyadmin for example. Let see the query work

Batouta commented on Jan 28, 2019

Thank you. I test the second seperatedly, the query work.

KoolReport commented on Jan 28, 2019

If you open the browser console, is there any javascript error showing when you try to click on the bar. please try to add this as well:

    console.log(params.selectedRow[0]); // Add this
    BeneficiaireLocalite.next({region:params.selectedRow[0]});

Do you see console.log showing correct region.

Batouta commented on Jan 28, 2019

the region is correct. i have 405 error

Batouta commented on Jan 28, 2019

I modify VerifyCsrfToken by adding protected $except = [

    //
	'/tbord'
];

and the problem is solved. But i don't know if it's the best way.... Thank you.

Hasvier Corporation commented on Jan 26, 2021

Hello Barouta. Can you explain about VerifyCsrfToken? Because i get the same error like you. What is "/tbord"?

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

DrillDown