Postingan lainnya
ordering datatable di codeigniter
permisi suhu, saya menggunakan datatable dan codeigniter, pada table tersebut mau saya order desc by id tablenya, saya order di model tetapi sepertinya tidak bekerja
function select_blood_donor_info()
{
$this->db->order_by('blood_donor_id','desc');
return $this->db->get('blood_donor')->result_array();
}
ini view datatable yang saya gunakan.
<tbody>
<?php foreach ($blood_donor_info as $row) { ?>
<tr>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['age'] ?></td>
<td><?php echo $row['sex'] ?></td>
<td><?php echo $row['blood_group'] ?></td>
<td><?php echo date("m/d/Y", $row['last_donation_timestamp']) ?></td>
<td>
<a onclick="showAjaxModal('<?php echo base_url();?>index.php?modal/popup/edit_blood_donor/<?php echo $row['blood_donor_id']?>');"
class="btn btn-default btn-sm btn-icon icon-left">
<i class="entypo-pencil"></i>
Edit
</a>
<a href="<?php echo base_url();?>index.php?laboratorist/blood_donor/delete/<?php echo $row['blood_donor_id']?>"
class="btn btn-danger btn-sm btn-icon icon-left" onclick="return checkDelete();">
<i class="entypo-cancel"></i>
Delete
</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<script type="text/javascript">
jQuery(window).load(function ()
{
var $ = jQuery;
$("#table-2").dataTable({
"sPaginationType": "bootstrap",
"sDom": "<'row'<'col-xs-3 col-left'l><'col-xs-9 col-right'<'export-data'T>f>r>t<'row'<'col-xs-3 col-left'i><'col-xs-9 col-right'p>>",
});
$(".dataTables_wrapper select").select2({
minimumResultsForSearch: -1
});
pertanyaannya kenapa datanya gak mau diorder berdasarkan descending ya, saya coba order di script datatablenya juga belum berhasil
4 Jawaban:
coba pake
$('#table-2').dataTable( {
"ordering": false
} );
biar ga di ordering, biar orderingnya berdasarkan, order dri model.. siapa tau bisa hehe
wahaha, belom berhasil yah.. , soalnya saya pernah itu di order lg ama datatable.. dan pake "ordering": false, normal.. , ntr ta cari lagi.. klo ga pake datatable.. di tampilin pake table biasa gmna? order nya bener? descending?
coba ini
$('#table-2').dataTable( {
"bSort": false,
"aoColumnDefs" : [ {
"bSortable" : false,
//"aTargets" : [ "no-sort" ]
} ]
});