DataTables

The minimum settings to get DataTables working

employeeNumber firstName lastName jobTitle extension
1002 Diane Murphy President x5800
1056 Mary Patterson VP Sales x4611
1076 Jeff Firrelli VP Marketing x9273
1088 William Patterson Sales Manager (APAC) x4871
1102 Gerard Bondur Sale Manager (EMEA) x5408
1143 Anthony Bow Sales Manager (NA) x5428
1165 Leslie Jennings Sales Rep x3291
1166 Leslie Thompson Sales Rep x4065
1188 Julie Firrelli Sales Rep x2173
1216 Steve Patterson Sales Rep x4334
1286 Foon Yue Tseng Sales Rep x2248
1323 George Vanauf Sales Rep x4102
1337 Loui Bondur Sales Rep x6493
1370 Gerard Hernandez Sales Rep x2028
1401 Pamela Castillo Sales Rep x2759
1501 Larry Bott Sales Rep x2311
1504 Barry Jones Sales Rep x102
1611 Andy Fixter Sales Rep x101
1612 Peter Marsh Sales Rep x102
1619 Tom King Sales Rep x103
1621 Mami Nishi Sales Rep x101
1625 Yoshimi Kato Sales Rep x102
1702 Martin Gerard Sales Rep x2312

Having myriad of features including paging, grouping, searching, DataTables is one of the best widgets to represent data in tabular format.

This example show the minimum settings to get DataTables working.

<?php 
    DataTables::create(array(
        "dataSource"=>$this->dataStore("employee")
    ));
?>

In above example, DataTables use DataStore as the source of data, beside the DataStore which is most used, DataTables like any other KoolReport's widget can receive data from array or direct SQL query.

Use array as datasource

<?php 
    DataTables::create(array(
        "dataSource"=>array(
            array("name"=>"Peter","age"=>35),
            array("name"=>"David","age"=>32),
        )
    ));
?>

or in table format

<?php 
    DataTables::create(array(
        "dataSource"=>array(
            array("name","age"),
            array("Peter",35),
            array("David",32),
        )
    ));
?>

Use SQL query directly

<?php 
    DataTables::create(array(
        "dataSource"=>$this->src("automaker")->query("SELECT * FROM employees")
    ));
?>
<?php
require_once "MyReport.php";

$report = new MyReport;
$report->run()->render();
<?php
//Step 1: Load KoolReport
require_once "../../../load.koolreport.php";

//Step 2: Creating Report class
class MyReport extends \koolreport\KoolReport
{
    function settings()
    {
        return array(
            "dataSources"=>array(
                "automaker"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=automaker",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"
                ),
            )
        ); 
    } 
    protected function setup()
    {
        $this->src('automaker')
        ->query("SELECT employeeNumber, firstName,lastName,jobTitle, extension from employees")
        ->pipe($this->dataStore("employees"));
    } 

}
<?php
    use \koolreport\datagrid\DataTables;
?>
<div class="report-content">
    <div class="text-center">
        <h1>DataTables</h1>
        <p class="lead">
        The minimum settings to get DataTables working
        </p>
    </div>
    
    <?php
    DataTables::create(array(
        "dataSource"=>$this->dataStore("employees"),
        "themeBase"=>"bs4", // Optional option to work with Bootsrap 4
        "cssClass"=>array(
            "table"=>"table table-striped table-bordered"
        )
    ));
    ?>
</div>

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro