I am using a datatable and not a table. the export should be done after the datatable was initialized in the client side.
DataTables::create(array(
"name" => "myTable",
"language" => "he", //use 'DataTables.de.json'
"emptyValue" => "", // use an empty string as filler for empty values
"dataSource"=>$this->dataStore("st"),
"options"=>array(
'ordering' => false,
"searching"=>true,
"paging"=>true,
'columnDefs' => array(
array(
//'visible' => false,
// 'targets' => [$this->monthDays+6,2,3], //hide the first column
)
),
'rowGroup' => [
'endRender' => "function ( rows, group ) {
var totalA = rows
.data()
.pluck($this->monthDays+4)
.reduce( function (a, b) {
return a + b.replace(/[^\d]/g,'')*1;
}, 0);
var totalB = rows
.data()
.pluck($this->monthDays+5)
.reduce( function (a, b) {
return a + b.replace(/[^\d]/g,'')*1;
}, 0);
var totalC = rows
.data()
.pluck($this->monthDays+6)
.reduce( function (a, b) {
return a + b.replace(/[^\d]/g,'')*1;
}, 0);
var totalD = rows
.data()
.pluck($this->monthDays+7)
.reduce( function (a, b) {
return a + b.replace(/[^\d]/g,'')*1;
}, 0);
return $('<tr/>')
.append( '<td colspan='+($this->monthDays+4)+'><b>$group_label '+group+'</b></td>' )
.append( '<td class=text-center><b>'+totalA+'</b></td>' )
.append( '<td class=text-center><b>'+totalB+'</b></td>' )
.append( '<td class=text-center><b>'+totalC+'</b></td>' )
.append( '<td class=text-center><b>'+totalD+'</b></td>' )
.append( '<td></td>' )
}",
],
),
"groupCellsInColumns" => [0, 1, 2], // group similar cells in 1st and 3rd columns
'complexHeaders' => true,
'headerSeparator' => ' - ',
'cssClass'=>array(
'table'=>'table table-bordered',
'tr'=>'cssItem',
'td'=>function($row,$colName)
{
return in_array($colName, array('substitute_teacher_id','id_number','substituted_teacher','group_name')) ? 'text-right' : 'text-center';
// if ($colName == 12) {
// return 'table-dark';
// }
},
'th'=>function($colName)
{
return in_array($colName, array('substitute_teacher_id','id_number','substituted_teacher','group_name')) ? 'table-dark text-right' : 'table-dark text-center';
},
),
));