KoolReport's Forum

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

Dashboard and PivotSQL #3339

Closed Marloes opened this topic on on Sep 19 - 12 comments

Marloes commented on Sep 19

Hi,

Could you please point me in the right direction. I want to implement PivotSQL into the Dashboard module... I can see an example with Pivot + .csv file as a database, but I need the PivotSQL with serverpaging. I cannot find any examples or documentation regarding the Dashboard.

Many thx.

With kind regards, Marloes

Sebastian Morales commented on Sep 20

PivotMatrix's serverPaging property works with both Pivot and PivotSQL processes. When using in Dashboard, you can enable serverPaging for PivotMatrix like this:

class CustomersPivotMatrix extends PivotMatrix
{
    protected function dataSource()
    {
        return AutoMaker::table("customer_product_dollarsales2")
                ->select('customerName', 'productLine', 'productName','dollar_sales')
                ->run() //After run(), we will get DataStore, we continue to process data with ColumnMeta 
                ->process(
                    ColumnMeta::process([
                        'dollar_sales'=>[
                            'type' => 'number',
                            'prefix' => '$',
                            'decimals'=>2,
                        ],
                    ])
                )
                ;
    }

    protected function process()
    {
        return [
            'dimensions'=>array(
                ...
            ),
            'aggregates'=>array(
                ...
            ),
        ];
    }

    protected function display()
    {
        return [
            'serverPaging' => true,
            'paging' => true,
            ...
        ];
    }

} 

If there's any issue let us know. Rgds,

Marloes commented on Sep 20

Thx Sebastian for your answer. It almost works as expected ... I have 1M rows and it still tries to load all at once while I'm expecting the dataset to load only partial onclick (by group/paging). Just like it does here: https://www.koolreport.com/examples/reports/pivot/pivotmatrix_server_paging/

With kind regards, Marloes

Sebastian Morales commented on Sep 23

Pls open your browser's dev tool, go to tab Network, click on XHR, then try changing PivotMatrix's page and see if there's xhr request. Try this as well on standalone PivotMatrix's serverPaging instead one of in Dashboard.

Marloes commented on Sep 23

Hi Sebastian,

The Standalone works properly for the serverpaging, I can see a clear XHR with request properties on koolPivotConfig, koolPivotViewState and so on.

The Dashboard version gives me: kdr[route], kdr[action] and state (with a base64 value) ... where de console.log gives an error on "e.state is null" for assets/app.js

Sebastian Morales commented on Sep 24

You can ignore the console message "e.state is null" for now. What is the behavior of Dashboard PivotMatrix, does its page change or not after upon xhr request is completed?

Marloes commented on Sep 24

Hi Sebstian,

The Dashboard version is changing pages but not as a serverload grouping query. What is seems to do is that it loads the complete dataset instead of using a LIMIT to only load the (grouped, sum) data according to the Pivot-page. There is also not a loader visible when changing pages.

Sebastian Morales commented on Sep 24

So far, PivotMatrix's serverPaging only has the ability to limit its output (page by page), not its input (SQL, CSV, etc) yet. Therefore you would see no limit clause in your SQL query. To limit the input as well requires further development down the road map of Pivot package. Hope this answer a part of your question.

Marloes commented on Sep 24

Hi Sebastian, this is not the answer I was looking for :-). Regardles the use or not of LIMIT ... the thing is that it doesn't behave like the standalone PivotSQL with Serverpaging. Instead it tries to load the entire Dataset of 1M rows ... while de standalone does it's job and only loads the data which belongs to the page requested.

So what do I have to do to get de Dashboard PivotSQL to behave like de standalone PivotSQL regarding serverpaging and the reloading of its data per page.

Marloes commented on Sep 24

When I zoom into PivotSQL.php on the method "nodesAndExpandedNodeToQuery", I can see that a query is rendered when using the standalone PivotSQL with serverpaging, ... but that the Dashboard version does not render such a query.

So do I need to insert something like ->pipe(new \koolreport\pivot\processes\PivotSQL([ ..]) Just as the standalone has?

Sebastian Morales commented on Sep 25

Your observation makes sense. Currently Dashboard's PivotMatrix uses the standard Pivot process. We will find a way for users to be able to use PivotSQL in Dashboard and let you know soon.

Marloes commented on Sep 25

Hi Sebastian, that would be awesome! Thank you very much for your response and answers, very much appreciated.

With kind regards, Marloes

Sebastian Morales commented on Sep 27

If you want to try a development version pls email us at support@koolreport.com and mention this topic. We will send you an updated Dashboard PivotMatrix widget with option to use PivotSQL process instead of Pivot one.

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

Dashboard