KoolReport's Forum

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

Table report in laravel #198

Open kezern opened this topic on on Jan 21, 2018 - 8 comments

kezern commented on Jan 21, 2018

I'm creating reports in laravel using koolreport. I have followed this guide and works fine. https://www.koolreport.com/blog/koolreport-and-php-framework Now I want to create a basic table report. I have included code based in Table Demo example. Results are shown, but I cant make pagination works. I'm getting errors some files are not found. vendor/koolreport/widgets/koolphp/table/table.css vendor/koolreport/clients/jquery/jquery.min.js I have included in my code in MyReport.view.php file use \koolreport\widgets\koolphp\Table;

Is there any tutorial I could follow?

Thanks!

KoolReport commented on Jan 21, 2018

You do this:

  1. In public folder of Laravel, you create sub folder called assets
  2. In your report settings function you put:
...
function settings()
{
    return array(
        "assets"=>array(
            "path"=>"{relative path from this report to assets folder}"
            "url"=>"/assets",
        ),
        ...
    );
}

The problem is because Laravel prohibit directly access to vendor folder. This above settings will tell KoolReport to copy js/css file to public folder where they can be accessed.

Let us know if you need any assistance.

kezern commented on Jan 21, 2018

Here is my code

function settings()
    {
        return array(
            "dataSources"=>array(
                "mydata"=>array(
                    "class"=>"\koolreport\datasources\ArrayDataSource",
                    "data"=>$this->params["data"],
                    "dataFormat"=>"associate",
                    "path"=>"../../public/assets",
                    "url"=>"/assets",
                ),
                "mydata2"=>array(
                    "class"=>"\koolreport\datasources\ArrayDataSource",
                    "data"=>$this->params["data2"],
                    "dataFormat"=>"associate",
                    "path"=>"../../public/assets",
                    "url"=>"/assets",
                ),

            )
        );

It still is showing error. Here is an snapshot

![(https://cdn.koolreport.com/assets/images/editor/c3/image5a64960cea51a.png)]

Thanks

KoolReport commented on Jan 21, 2018

No, The path and url is inside “assets” property which is the same level with “dataSources”

kezern commented on Jan 21, 2018

The same error. I have now this code.

function settings()
    {
        return array(
            "dataSources"=>array(
                "mydata"=>array(
                    "class"=>"\koolreport\datasources\ArrayDataSource",
                    "data"=>$this->params["data"],
                    "dataFormat"=>"associate",
                    "assets"=>array(
                        "path"=>"../../public/assets",
                        "url"=>"/assets",
                    ),

                ),
                "mydata2"=>array(
                    "class"=>"\koolreport\datasources\ArrayDataSource",
                    "data"=>$this->params["data2"],
                    "dataFormat"=>"associate",
                    "assets"=>array(
                        "path"=>"../../public/assets",
                        "url"=>"/assets",
                    ),
                ),

            )
        );
    }
KoolReport commented on Jan 21, 2018

You are putting “assets” property inside “dataSources” which is not correct. They are in the same top level.

return array(
  “assets”=>array(..),
  “dataSources”=>array(
    “mydata”=>array(...),
    “mydata2”=>array(...)
  )
);
kezern commented on Jan 21, 2018

Great!! That worked!! Thank you very much!!

KoolReport commented on Jan 21, 2018

Awesome!

Rudi Ullon commented on Aug 27, 2018

I worked out this problem with this settings, the problem was that my laravel report was on a deeper path (events/reports/report_name), but the script src was pointing to "koolrepor_assets_xxx", so the browser was looking in the path starting from the report route. This solved that.

function settings()
    {
        return [
            "assets"    => [
                "path"=>"koolreport_assets",
                "url"=>"/koolreport_assets"
            ]
        ];

    }

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

None