KoolReport's Forum

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

Report View Table Widget - How can I set Row Limit? #2487

Closed hsw opened this topic on on Dec 10, 2021 - 4 comments

hsw commented on Dec 10, 2021

Hi,

I am creating a new summary table from an existing dataStore. The dataStore has x number of rows. For this summary table, I just need to display the first 3 rows of data. Instead of creating another dataStore containing only the first 3 rows, can I set the row limit at the Table Widget in Report View php file?

Thank you.

Sebastian Morales commented on Dec 10, 2021

Pls try DataStore's slice method like this:

//MyReport.view.php
$newDS = $this->dataStore("myDatastore")->slice(0, 3); // return a datastore with 3 rows starting from index 0, i.e the first 3 rows.
hsw commented on Dec 10, 2021

Thanks for replying.

I tried, but I got "no data available in table". Did I do it correctly?

In myReport.php

$this->src('packages')
        ->pipe(new Filter(array(
          .....
        )))
        .....
        ->pipe($this->dataStore('myDatastore'));

$newDS = $this->dataStore('myDatastore')->slice(0, 3);

In myReport.view.php

<?php
   Table::create(array(
       "dataStore"=>$this->dataStore('newDS')
   ));
?>
KoolReport commented on Dec 10, 2021

You need to put that slice code at view file. If you put at setup, it will not run (no data at that time to run). You remove that code inside setup() and do this in the view:

<?php
   Table::create(array(
       "dataStore"=>$this->dataStore('myDatastore')->slice(0, 3)
   ));
?>
hsw commented on Dec 21, 2021

Thanks for the guidance. It's working. :D

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