DataTable with codeigniter + SB Admin 2

DataTable with codeigniter + SB Admin 2

CharlieFakeCharlieFake Posts: 2Questions: 1Answers: 0

Hello everybody,
i am new in datatable and would like to use it for my website.
I am using codeigniter 3 with a boostrap4 template (SB Admin2). and I would like to use datatable to display the many tables that I am going to create on the site.
But at my fist table DataTable doesn't work.

The header is:
<head>

<meta charset="utf-8">

<link href="<?= base_url('assets/vendor/fontawesome-free/css/all.min.css');?>" rel="stylesheet" type="text/css">
<link ref="https://fonts.googleapis.comcss?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<link href="<?= base_url('assets/css/sb-admin-2.min.css');?>" rel="stylesheet">


<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.js"></script>

</head>

The body code is:
<body>
<div class="col-xl-8 col-lg-7">
<table id="mese" class="table table-bordered dataTable">
<thread>
<tr>
<th>PVR</th>
<th>Giocato</th>
<th>Vinto</th>
<th>GGR</th>
<th>Bonus</th>
<th>Aggio Novobet</th>
<th>Aggio PVR</th>
</tr>
</thread>
<tbody>
<?php
foreach ($giornaliero->result() as $item_day):{?>
<tr>
<td>echo $item_day->pvr ?></td>
<td>echo $item_day->giocato ?></td>
<td>echo $item_day->vinto ?></td>
<td>echo $item_day->ggr ?></td>
<td><?php echo $item_day->bonus ?></td>
<td><?php echo $item_day->aggio_novobet ?></td>
<td><?php echo $item_day->aggio_pvr ?></td>
</tr>
<?php } endforeach;
foreach ($totale->result() as $total):{?>
<tr style="font-weight: bold;">
<td>TOTALE</td>
<td><?php $total->giocato ?></td>
<td><?php $total->vinto ?></td>
<td><?php echo $total->ggr ?></td>
<td><?php echo '$total->bonus ?></td>
<td><?php echo $total->aggio_novobet ?></td>
<td><?php echo $total->aggio_pvr ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>

Finally in the footer there is this code:

<script type="text/javascript">
$.extend( true, $.fn.dataTable.defaults, {
"searching": true,
"ordering": true,
paging": true
} );
$(document).ready(function()
{
$('#mese').dataTable( {
"lengthMenu": [ 5,10,15,20,25,30,35,50,75,100 ],
"order": [[ 5, "desc" ]],
"pagingType": "full_numbers"
} );
} );
</script>

<script src="<?= base_url('assets/vendor/jquery/jquery.min.js')?>"></script>
<script src="<?= base_url('assets/vendor/bootstrap/js/bootstrap.bundle.min.js')?>"></script>
<script src="<?= base_url('assets/vendor/jquery-easing/jquery.easing.min.js')?>"></script>
<script src="<?= base_url('assets/js/sb-admin-2.min.js')?>"></script>
<script src="<?= base_url('assets/vendor/chart.js/Chart.min.js')?>"></script>
<script src="<?= base_url('assets/js/demo/chart-area-demo.js')?>"></script>
<script src="<?= base_url('assets/js/demo/chart-pie-demo.js')?>"></script>

</body>

if I use this portion of code without the sb admin2 template, only with codeigniter, Datatable works
Why? Where am i worng in sb admin template?

Thanks and best regards!
Carlo

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • CharlieFakeCharlieFake Posts: 2Questions: 1Answers: 0

    Hi Colin,
    I solved.
    Thanks anyway,
    Best regards
    Carlo

  • wahyu_cwahyu_c Posts: 1Questions: 0Answers: 0

    Hi Charlie,
    how can you fix that? i got the same problem with you.

  • EmmanuelfkEmmanuelfk Posts: 1Questions: 0Answers: 0

    I also got the same problem using SB admin 2 template bootstrap and my DataTable is not loading the data

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    As Colin mentioned, if you can give us a link to a page showing the issue, we'd be happy to take a look and try to help resolve it.

    Allan

Sign In or Register to comment.