KoolReport's Forum

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

Multiple DataSource in view.php #1524

Closed David Vanacore opened this topic on on Jul 12, 2020 - 1 comments

David Vanacore commented on Jul 12, 2020

Is it possible to have multiple Datasources in the view.php file with queries in them?

DataTables::create(array(
        'name' => 'Table1',
        "cssClass"=>array(
            "table"=>"table table-striped table-bordered"),
        'dataSource' => function() {
            return $this->src('mysql2')
            ->query('SELECT * FROM TABLE')
            ->params(array( ":startDate"=>$this->params["startDate"],
        ));
David Winterburn commented on Jul 13, 2020

Yes, you can use multiple sources and queries in the dataSource property of Table or DataTables like this:

                    'dataSource' => function($scope) {
                        $node = $this->src('mysql')
                        ->query('select * from customer_product_dollarsales2')
                        ->pipe(new \koolreport\core\Process())
                        ;

                        $this->src('mysql')
                        ->query('select * from customer_product_dollarsales2')
                        ->pipe($node);

                        return $node;
                    }, 

The only caveat is that using this with DataTables' server side processing isn't perfect yet. The data from multiple sources/queries would be there but total number of record wouldn't be correct. We are trying to solve the total record metadata for DataTables' server side when there're multiple sources. Thanks!

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
None yet

None