KoolReport's Forum

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

Drilldown package usage #449

Open Eric opened this topic on on Sep 5, 2018 - 9 comments

Eric commented on Sep 5, 2018

Hello, I have some questions pertaining to the drilldown package. I need to display a table that groups the rows by "statuses" as the pic below. How can I use the drilldown package to display another table of all the rows columns for a given statuses when I click on a bar? The simple query I use to display the first table is something like:

SELECT statuses, count(*) as nb FROM sampleTable

Thank you for your help

KoolReport commented on Sep 5, 2018

The DrillDown widget will not work in this case. You need to use the CustomDrillDown. The custom drill down will require you to setup 1 main report and 2 subreports. The main report will contains the CustomDrillDown. Two sub reports will be StatusSummary and DetailStatus. The StatusSummary report will be exactly like what you have done, group by status and count number. The DetailStatus will have different query in which it takes status as a parameter and list all the related rows which has that status.

Then in the select event of the ColumnChart in StatusSummary sub report, you will call next() function of drilldown to move to the next level (drilldown will load the DetailStatus sub report)

For more details of how to setup the CustomDrillDown, please have a look at our customdrilldown report in the examples suite.

Please let us know if you have any difficulty.

Eric commented on Sep 5, 2018

Thanks for the reply. I'm still having some difficulties. When I click on the status bar, it goes to the next report "DetailStatus.view" but it is always blank. What am I doing wrong?

MainReport

    function settings() {
        return array(
            "subReports"=>array(
                "name"=>"Status",
                "title"=>"Trip by Status",
                "statusSummary"=>StatusSummary::class,
                "detailStatus"=>DetailStatus::class,
            )
        );
    }

MainReport.view

 \koolreport\drilldown\CustomDrillDown::create(array(
        "status"=>"status",
        "subReports"=>array("statusSummary","detailStatus"),
    ));

StatusSummary

function setup() {
      $this->src('dataSource')
          ->query("SELECT status, count(*) as nb FROM SampleTable GROUP BY status")
          ->pipe($this->dataStore('status_summary'));
  }

StatusSummary.view

ColumnChart::create(array(
    "dataStore"=>$this->dataStore('status_summary'),
    "clientEvents"=>array(
        "itemSelect"=>"function(params){
              $drilldown.next({status:params.selectedRow[0]});
        }",
    ),

DetailStatus

 function setup() {
    $this->src('dataSource')
    ->query("SELECT * FROM SampleTable WHERE status=:status")
    ->params(array(
        ":status"=>$this->params["status"]
    ))
    ->pipe($this->dataStore('detail_report'));
  }

DetailStatus.view

ColumnChart::create(array(
    "dataSource"=>$this->dataStore("detail_report")
KoolReport commented on Sep 6, 2018

Hi Eric,

In the DetailStatus.view, please change to use Table instead of ColumnChart.

Table::create(array(
    "dataSource"=>$this->dataStore("detail_report")
))
Eric commented on Sep 6, 2018

I tried using Table but to no avail. It seems that the DetailStatus.view is never called. Any pointer is appreciated. It display "Level 1" as a chart title and nothing else Thanks

KoolReport commented on Sep 6, 2018

Can you post the whole code of DetailStatus.view

Eric commented on Sep 6, 2018

Here it is

<?php
    require_once("../includes/config.php"); //Load the configurations
    use \koolreport\widgets\koolphp\Table;
    $drilldown = $this->params["@drilldown"];
?>

<level-title><?php echo "Status selected: ".$this->params["status"]; ?></level-title>

<?php
Table::create(array(
    "dataSource"=>$this->dataStore("detail_report"),
    "columns"=>array("status", "id", "activityCode")
));
?>
KoolReport commented on Sep 6, 2018

Oh I am sorry, it should the StatusSummary.view

Eric commented on Sep 6, 2018

I just got it working - I had a typo in the DetailStatus. Thanks for your help!

KoolReport commented on Sep 6, 2018

That's great!

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