my target is to export my table into pdf in the same format. Currently, when I am exporting my table to PDF, the format is not the same in my view.
This is what happens after I export it into PDF
Any guide or help will be appreciated. Thank you so much and have a nice day
View:
<table id="notable" class="table test table-striped is-narrow is-hoverable is-fullwidth text-nowrap" style="width:100%; ">
<thead>
<tr>
<th>NO.</th>
<th>ENTRYNAME</th>
<th>WB</th>
<th>LB</th>
<th>WT</th>
<th>NO.</th>
<th>#</th>
<th>ENTRY NAME</th>
<th>WB</th>
<th>LB</th>
<th>WT</th>
<th>DIFF</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Script:
var no=$('#notable').DataTable({
dom: 'Blfrtip',
'pageLength':20,
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
buttons: [
'print', 'csv', 'copy', 'excel', 'pdfHtml5'
],
"serverSide": true, //Feature control DataTables' server-side processing mode.
"order": [], //Initial no order.
// Load data for the table's content from an Ajax source
"ajax": {
"url": "<?php echo site_url('controller/function')?>",
"type": "POST",
"data": function ( data ) {
data.eventID = $('#eventID').val();
}
},
rowGroup: {
dataSrc: 1
},
columnDefs: [{
"defaultContent": "-",
"targets": "_all",
"width": "1%", "targets": 0
},
],
});
Controller:
public function matchlist()
{
$count = 1;
$list = $this->repo->get_datatables();
$data = array();
$no = $_POST['start'];
$countnew = '1';
$check_arr = array();
foreach ($list as $person1) {
$no++;
if($person1->weightM>$person1->weightW){
$sum=$person1->weightM-$person1->weightW;
}else{
$sum=$person1->weightW-$person1->weightM;
}
if(!empty($check_arr) && !in_array($person1->handlerM, $check_arr)) {
$countnew = 1;
}
$row = array();
$row[]= $countnew++;
$row[] = $person1->handlerM ;
$row[] = $person1->wingBandM;
$row[] = $person1->legBandM;
$row[] = $person1->weightM;
$row[] = $person1->fightNumber;
$row[] = $person1->handlerIDW;
$row[] = $person1->handlertestW;
$row[] = $person1->wingBandW;
$row[] = $person1->legBandW;
$row[] = $person1->weightW;
$row[] = $sum;
$data[] = $row;
$check_arr[] = $person1->handlerM;
}
$output = array(
"draw" => $_POST['draw'],
"recordsTotal" => $this->repo->count_all(),
"recordsFiltered" => $this->repo->count_filtered(),
"data" => $data,
);
//output to json format
echo json_encode($output);
}

