KoolReport's Forum

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

(Subreport) use parentReport's dataStore on childReport's dataStore #186

Open dimasmaliq opened this topic on on Jan 8, 2018 - 8 comments

dimasmaliq commented on Jan 8, 2018

is it possible to use the dataStore in childReport that was defined at parentReport without redefine these dataStore in childReport?

KoolReport commented on Jan 8, 2018

Better you create a BaseReport (derived from KoolReport) which hold the settings() function with dataSources definition. Then your parent report as well as child report can be derived from BaseReport. By this way you will not to setup dataSources on each report.

dimasmaliq commented on Jan 8, 2018

can you give me an examples, please?

KoolReport commented on Jan 8, 2018

Please view this topic.

dimasmaliq commented on Jan 8, 2018

based on this topic above, my question is how to use data from basereport's datastore in childreport without resetup this in childreport's 'setup' method.

for example, this is my "basereport.php":

class BaseReport extends \koolreport\KoolReport
{
    function settings()
    {
            return array(
                "dataSources"=>array(
                    "sale"=>array(...),
                    "marketing"=>array(...),
                    "other_source"=>array(...),
                )
            )
    }
    function setup()
    {
        $this->src("sale")
        ->pipe($this->dataStore("abcdefg"));
    }
}

how to call $this->dataStore("abcdefg") in "childReport.view.php" without re-setup these datastore ini "childReport.php"?

KoolReport commented on Jan 8, 2018

Here is the sample code

class BaseReport
{
    function settings()
    {
            return array(
                "dataSources"=>array(
                    "sale"=>array(...),
                    "marketing"=>array(...),
                    "other_source"=>array(...),
                )
            );
    }
}

class ParentReport extends BaseReport
{
    use \koolreport\core\SubReport;
    function setup()
    {
        $this->src("sale")->pipe(...)
    }
}
class ChildReport extends BaseReport
{
    function setup()
    {
        $this->src("sale")->pipe(...)
    }
}
dimasmaliq commented on Jan 8, 2018

let say, i've define datastore named "abcdef" on ParentReport.php like this:

class ParentReport extends BaseReport
{
    use \koolreport\core\SubReport;
    function setup()
    {
         $this->src("sale")->pipe($this->dataStore("abcdefg"))
    }
}

and that dataStore was used in ParentReport.view.php

my question is, how if i wrote ChildReport.php and ChildReport.view.php which is ChildReport.view.php want to used the 'abcdefg' ParentReport's datastores. should i re-write $this->src("sale")->pipe($this->dataStore("abcdefg")) on ChildReport.view.php?

KoolReport commented on Jan 8, 2018

ChildReport should be independent from ParentReport. It should be able to standalone with its own data query. It is possible to transmit dataStore of parent to child report but when subReport is updated via ajax, those data will not be available. That's why it should be an independent report. Please rewrite the pipe in childreport.

dimasmaliq commented on Jan 8, 2018

okey. thanks for your response :') it answered my question

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

None