pagination datatable not working, showing all records at a time.
pagination datatable not working, showing all records at a time.
wulanyaya
Posts: 5Questions: 1Answers: 0
hye, i'm doing pagination using datatable. the table seems like to be okay. but the problem is, it show all records at a time. the total records is 298. it shows all 298 records in 1 page. however i just want to show 10 records per page. the pagination n searching is not working .
This discussion has been closed.
Answers
on head section ;
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link src="<?php echo base_url('assets/datatable/datatables.min.css') ?>">
<link href="<?php echo base_url('assets/css/bootstrap.css') ?>" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/datatable/datatables.min.css') ?>"/>
</head>
now inside the body (the thead) ;
<body>
<
div class="mytable">
<
table id="geran" class="table table-striped table-bordered table-hover datatable" cellspacing="0" width="100%">
<thead>
<tr>
<th><h3>Kolaborasi Penyelidikan Terkini</h3></th>
</tr>
</thead>
now inside the body (the tbody) ;
<tbody>
<tr>
<td>
<?php echo $num; ?>
<i class="fa fa-hand-o-right"></i>
<?php $idpjk = $geran['kodprojek']; ?>
<?php $akdpjk = '';
foreach ($all_grant as $ahligeran) {
if ($akdpjk === $idpjk) {
?>
<span class="font-new"><a href="<?php echo base_url('main/lihat_profil/'.$ahligeran['noper']);?>" target="_blank" data-toggle="tooltip" data-placement="right" title="View detail">
<?php echo $ahligeran['nama']; ?>,
<?php } ?></a></span>
<?php $akdpjk = $ahligeran['kodprojek'];}?>
<span class="font-new"><?php echo $geran['tajuk']; ?></span>
<span class="font-new"><?php echo $geran['kolaborator']; ?></span>
<span class="font-new"><i>(<?php echo $mula;?> - <?php echo $tamat; ?>)</i></span><br>
</td>
</tr>
</tbody>
<?php }} ?>
</table>
and the script section ;
">
$(document).ready(function() { $('#geran').DataTable({ "ordering": true, "bLengthChange" : true, "pageLength": 10, "searching": true, }); } );">
</div>
Sounds like Datatables might not be fully loading due to a Javascript error. Have you checked your browser's console for errors?
Kevin