I'm using Jquery datatables library since a long time in server side processing but I encountered lot of problem when I use filter search because the rendered data isn't the same value of the database value.
So I have a new project and I decide to use datatables client side. So I have an ajax call to get all my data. But php is really slow if I do queries with relationship on 100 000 rows.
Then the idea is to use a limit to display some data to the client and processing in background and display all result when it's ok. I see deferRender method in datatables documentation but I don't see any changes.
So I do an first ajax call with a limit parameter, I display the results and I do a second ajax call without limit parameter, then I display all result.
The problem with that is the number of the total record... When the table is populate with the first call I have the total record of the limit so I don't have the real total record number. It's initialized at the second time.
How can I edit the total record number to display the final pagination and the final "Showing x to y of z entries" at the first call ? Or maybe I'm doing wrong and there is another good way to do what I want.
Here is my datatable initialization :
$('#foldersTable').DataTable({
dom: "t<'col-sm-5'i><'col-sm-7'p>",
autoWidth: false,
serverSide: false,
aaSorting: [[2, 'desc']],
createdRow: addDataAttr,
drawCallback: keepSelectedRow,
rowId: 'id',
lengthChange: false,
iDisplayLength: 10,
deferRender: true,
initComplete: function(settings, json) {
$('.table-responsive').show();
limit = false;
$('#foldersTable').DataTable().ajax.reload(null, false);
},
ajax: {
url: 'getFolders',
method: 'POST',
dataSrc: checkSessionDT,
data : { "limit" : function() { return limit; } }
},
language: {
lengthMenu: datatable_lang.lengthMenu,
zeroRecords: datatable_lang.zeroRecords,
info: datatable_lang.info,
infoEmpty: datatable_lang.infoEmpty,
infoFiltered: datatable_lang.infoFiltered,
search: datatable_lang.search,
searchPlaceholder: datatable_lang.searchPlaceholder,
paginate: {
previous: datatable_lang.paginate.previous,
next: datatable_lang.paginate.next
}
},
columns: [
{data: "Column A", width:"20%"},
{data: "Column B", width:"20%", orderData:[1, 0]},
{data: "Column C", render: renderFunction, width:"20%", orderData:[2, 0], type: "date-euro"},
{data: "Column D", width:"20%", orderData:[3, 0]},
{data: "Column E", width:"20%", orderData:[4, 0]}
]
});
I hope you can help me.