I think a general solution is to divide the data into two datastores and display both with Table widgets. The first Table doesn't show headers while the second one does. To divide a pipe to two datastores you could use the Map process like this:
->query($sql)
->pipe(new Transpose())
->pipe(new ColumnRename(array(
"c0"=>"description",
"c1"=>"amount"
)))
->saveTo($tmpNode);
$tmpNode->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row, $metaData, $index, $mapState) {
if ($inddex < 5) return $row; // pipe the first 5 rows
else return null; // doesn't pipe the rest of rows
}
))
->pipe($this->dataStore("First5RowsDatastore"));
$tmpNode->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row, $metaData, $index, $mapState) {
if ($inddex >= 5) return $row; // pipe rows after the first 5 ones
else return null; // doesn't pipe the first 5 rows
}
))
->pipe($this->dataStore("RestOfRowsDatastore"));
Or you could insert the header to the middle of your data:
->query($sql)
->pipe(new Transpose())
->pipe(new ColumnRename(array(
"c0"=>"description",
"c1"=>"amount"
)))
->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row, $metaData, $index, $mapState) {
$headerRow = [ "description" => "Description", "amount" => "Amount" ];
if ($index === 5) return [$headerRow, $row];
else return $row;
}
))
->pipe($this->dataStore("allDataStore"));
Then in your Table widget, use "cssClass"'s "tr" to decide if a row is the inserted header row and add a specific class for it to make its font bold:
Table::create(array(
"dataSource" => $this->dataStore("allDataStore"),
"showHeader" => false,
"cssClass" => array(
"tr" => function($row) {
// if $row looks like a header row return some class like "inserted-header-row"
// else return ""
}
...
?>
<style>
tr.inserted-header-row td {
font-style: bold;
}
</style>