How to use pagination for LIMIT QUERY JSON var source Datatables
How to use pagination for LIMIT QUERY JSON var source Datatables
Hello.
Greetings from me. I've just developed datatables using JSON, due to alway failed when using Ajax, I decided to create it manually and it works like a charm
$('#btn_search').click(function(e){
e.preventDefault();
$.post(
'<?=site_url('master/pengguna/list_by_criteria')?>',
{
username: $("#txb_username").val(),
csrf_token:'<?=$csrf_hash?>'
},
function(json_data)
{
refresh_datatables($("#dt_table").DataTable(),json_data)
}
);
});
function refresh_datatables(dt_table,json_data)
{
dt_table.clear();
for (var i=0; i<json_data.length; i++)
{
dt_table.row.add(json_data[i]);
}
dt_table.draw();
}
My question is, when dealing with large data, I want to limit query (e.g: mysql via LIMIT or mssql via ROWNUM) before they send as json. But I want to display pagination.It aims not only for user information but also as a param when I send request to NEXT page (using page.info().page)
I tried to LIMIT only 5 rows. But unfortunately, the pagination didn't show.
Please kindly help me
Thank you in inadvance