KoolReport's Forum

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

Dashboard dataStore access #2781

Closed GHSix opened this topic on on Aug 2, 2022 - 2 comments

GHSix commented on Aug 2, 2022

I see from the KPI Dashboard Product Demo how to access dataSource to reload it with new params from a selected value.

Now, is it possible to query the data without filtering and do the filter on dataStore only, without rerun the query?.

IE:

  1. dataSource query a SELECT * FROM TABLE.
  2. User click on chart to Filter the Table by the selected Value.
  3. The selected Value is used to filter the dataStore insted of rebuild the results from dataSource.
  4. Now I have this interactive dashboard that do a single query once.

Also, would too be possible to share a dataSource between widgets. So we have this single query running once and ploting different charts on screen?

KoolReport commented on Aug 3, 2022

It is possible to share data between widgets, you can make Dashboard to host data like this:

class MyDashboard extends Dashboard
{
    protected $sharedData;
    public function getSharedData()
    {
        if($this->sharedData==null)
        {
            $this->sharedData = AutoMaker::table("mytable")->run();
        }
        return $this->sharedData;
    }
}

Now in any widgets inside that dashboard would like to use the data, you can do:

class MyTable extends Table
{
    protected function dataSource()
    {
        return $this->dashboard()->getSharedData();
    }
}

Hope that helps.

GHSix commented on Aug 3, 2022

Nice, it works.

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
solved

None