KoolReport's Forum

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

Get number of rows when rendering? #253

Open Tyler Neal opened this topic on on Apr 19, 2018 - 5 comments

Tyler Neal commented on Apr 19, 2018

Is there a way to get the number of rows in a table when it's rendered? I want to hide the table if there is no data.

KoolReport commented on Apr 19, 2018

Hi Tyler,

You may use the $this->dataSource("mystore")->countData() it will return the number of rows in that dataStore. So basically you can check it and decide whether to render Table.

FYI, the DataStore has numerous useful functions that you can play with data. View here.

Regards,

KoolPHP Inc

Tyler Neal commented on Apr 20, 2018

Would it be used in this context? When rendering? This is not rendering at all regardless of the data.

<? if($deniedDevices->dataStore('DeniedDevices')->countData() > 0) { ?>
                <h4>Denied Devices</h4>
                <? $deniedDevices->run()->render(); ?><? } ?>
KoolReport commented on Apr 20, 2018

So I guess $deniedDevices is a report, is it?

So you do this:

<?php
$deniedDevices = new DeniedDevicesReport;
$definedDevices->run(); // <-- Need to run report first to get result
if($deniedDevices->dataStore("DeniedDevices")->countData()>0)
{
    $deniedDevices->render();
}
Tyler Neal commented on Apr 20, 2018

Yup that was it, didn't realize you had to run it first.

Thank you!

KoolReport commented on Apr 20, 2018

Thank you very much for your tips :) We are happy to serve you!

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