You may set custom formatting for column. In this example, we show the red color for those income lower than $70,000 and make it green for income greater than $70,000.
<?php
Table::create(array(
"dataSource"=>$this->dataStore('data'),
"columns"=>array(
"name",
"age",
"income"=>array(
"formatValue"=>function($value,$row)
{
$color = $value>70000?"#718c00":"#e83e8c";
return "<span style='color:$color'>$".number_format($value)."</span>";
}
)
),
));
?>
<?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
{
protected function settings()
{
return array(
"dataSources"=>array(
"data"=>array(
"class"=>'\koolreport\datasources\ArrayDataSource',
"dataFormat"=>"table",
"data"=>array(
array("name","age","income"),
array("John",26,50000),
array("Marry",29,60000),
array("Peter",34,100000),
array("Donald",28,80000),
)
)
)
);
}
protected function setup()
{
$this->src("data")
->pipe($this->dataStore("data"));
}
}
<?php
use \koolreport\widgets\koolphp\Table;
?>
<div class="report-content">
<div class="text-center">
<h1>Format Value</h1>
<p class="lead">How to set your own custom value format for a column</p>
</div>
<?php
Table::create(array(
"dataSource"=>$this->dataStore('data'),
"columns"=>array(
"name",
"age",
"income"=>array(
"formatValue"=>function($value,$row)
{
$color = $value>70000?"#718c00":"#e83e8c";
return "<span style='color:$color'>$".number_format($value)."</span>";
}
)
),
"cssClass"=>array(
"table"=>"table-bordered table-striped table-hover"
)
));
?>
</div>