Can i rename recordsFiltered or make datattables take the totalElements?
Can i rename recordsFiltered or make datattables take the totalElements?
Januraj
Posts: 85Questions: 18Answers: 0
the response of the serverside ajax call looks like
{
data: [].
paging: {
count: 10
page: 0
totalElements: 356
totalPages: 36
}
}
but the datatable takes the response in different way with recordsFiltered and recordsTotal
Can i rename it or make datattables take the totalElements?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
That's not the format expected for
serverSide
. The protocol is discussed here. Also see examples here.Cheers,
Colin
how about the below code:
$('#myTable').DataTable( {
serverSide: true,
ajax: {
url: '/api/data',
dataFilter: function(data){
var json = jQuery.parseJSON( data );
json.recordsTotal = json.total;
json.recordsFiltered = json.total;
json.data = json.list;
}
} );
wont this thing work for renaming it?
Well, that means the count won't work as the filtered count is fixed to the number of records. I would suggest changing the server script to comply with the expectations of the client.
Or, if you haven't got many records, say less that 50k records, you could remove the
serverSide
and use client-side processing.Colin
Thanks @colin