Paging and Order in Data Tables not working
Paging and Order in Data Tables not working
xyta
Posts: 3Questions: 2Answers: 0
Hello, i have a data table in laravel. The data was displayed successful, but the pagination and order not working. the recordTotal is not same with total data in database. It still display 10 data
this is my javascript in laravel
<script>
$(function () {
var ObjDt = $(".bnp-table").DataTable({
pageLength: 20,
processing: true,
serverSide: true,
ajax: {
url: "{{ url('/cekstatustki')}}",
"data": function ( d ) {
d.pencarian = "{{ $kategori }}";
d.nama = "{{ $nama }}";
d.negara = "{{ $negara }}";
//d.pageby = "1";
},
dataType : "json",
type: "GET"
},
columns: [
{data: 'TKI_TKIID', name: 'TKI_TKIID'},
{data: 'TKI_TKINAME', name: 'TKI_TKINAME'},
{data: 'TKI_TKICITYDESC', name: 'TKI_TKICITYDESC'},
{data: 'TKI_NEGARADESC', name: 'TKI_NEGARADESC'},
{data: 'TKI_PJTKIDESC', name: 'TKI_PJTKIDESC'},
{data: 'TKI_PJTKADESC', name: 'TKI_PJTKADESC'},
{data: 'TKI_STATUS', name: 'TKI_STATUS'},
{data: 'TKI_TANGGAL', name: 'TKI_TANGGAL', searchable: false},
],
"oLanguage": {
"sProcessing": "Sedang memproses...",
"sLengthMenu": "Tampilkan _MENU_ entri",
"sZeroRecords": "Tidak ditemukan data yang sesuai",
"sInfo": "Menampilkan _START_ sampai _END_ dari _TOTAL_ entri",
"sInfoEmpty": "Menampilkan 0 sampai 0 dari 0 entri",
"sInfoFiltered": "(disaring dari _MAX_ entri keseluruhan)",
"sInfoPostFix": "",
"sSearch": "Cari:",
"sUrl": "",
"oPaginate": {
"sFirst": "Pertama",
"sPrevious": "Sebelumnya",
"sNext": "Selanjutnya",
"sLast": "Terakhir"
}
},
"rowReorder": {
"selector": 'td:nth-child(2)'
},
"responsive": true
}
);
ObjDt.on( 'search.dt order.dt page.dt', function () {
var info = ObjDt.page.info();
var length = ObjDt.column( 0 ).data().length;
alert("info: " + info + "\ninfo.page: " + info.page + "\ninfo.pages: " + info.pages);
ObjDt.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = (info.page)*length+i+1;
});
});
$.fn.dataTable.ext.errMode = 'throw';
});
</script>
This is the output from json
{"draw":1,"recordsTotal":10,"recordsFiltered":10,"data":}.
Thank you
This discussion has been closed.
Answers
The pagination, sorting, searching and the recordsTotal, etc are the responsibility of your server side script. The requirements for server side processing are described here:
https://datatables.net/manual/server-side
What are you using for your server side script?
Kevin