pagination datatable not working, showing all records at a time.

pagination datatable not working, showing all records at a time.

wulanyayawulanyaya Posts: 5Questions: 1Answers: 0
edited October 2017 in Free community support

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 .

Answers

  • wulanyayawulanyaya Posts: 5Questions: 1Answers: 0

    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>

  • wulanyayawulanyaya Posts: 5Questions: 1Answers: 0

    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>

  • wulanyayawulanyaya Posts: 5Questions: 1Answers: 0

    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>

  • wulanyayawulanyaya Posts: 5Questions: 1Answers: 0

    and the script section ;

    ">

    ">

    $(document).ready(function() { $('#geran').DataTable({ "ordering": true, "bLengthChange" : true, "pageLength": 10, "searching": true, }); } );

    </div>

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Sounds like Datatables might not be fully loading due to a Javascript error. Have you checked your browser's console for errors?

    Kevin

This discussion has been closed.