DataTable |
Controllers
public function get_data() {
$list = $this->daftar_m->getData();
$recordsTotal = count($list);
foreach($list as $key){
$arr = array();
$arr[] = $key->namakolom;
$datanya[] = $arr;
}
$output = array(
"recordsTotal" => $recordsTotal,
"data" => $datanya,
);
echo json_encode($output);
}
Models
//query kamu di model daftar_m
View
<table class="table table-bordered table-striped" id="table">
<thead>
<tr>
<th style="vertical-align: middle" class="text-center" width="5%">Nama</th>
</tr>
</thead>
</table>
JavaScript
$(document).ready(function () {
var sourcenya = "<?php echo site_url('spp_tu/get_pilih_paket_kegiatan/' . enkripsi($kgo_key) . '/' . enkripsi($uk_paket)) ?>";
var oTable = $('#table').DataTable({
"bSort": false,
"sAjaxSource": sourcenya,
"processing": true,
// columns: [//deklarasi thead
// {data: "namakolom"}
// ]
});
Sekian, terimakasih atas kunjungannya.
Salam,
EmoticonEmoticon