datatable pagelength
datatable pagelength

I need to display the total number of records displayed in each page and it should increase on next page if data avaiable. For example I have 50 records on first page and I will show text as "showing 50 of total(server side length) records and in next page if data is there then I need to show as "showing 50 to 100 of total(server side length) records. Is that possible?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can use the
infoCallback
and within the function you can decide if its the first page to display in one format otherwise display in the other format.Kevin
Yeah I have used but even though its still displaying as "showing 50" its not increasing.
"infoCallback": function( settings, start, end, max, total, pre ) {
var elements = $('#DriverListTable tbody tr').size();
return 'Showing '+ (elements) + ' of ' + (pageLength) +' records';
}
That's not how the paging works I'm afraid. It needs to know the total amounts from the beginning. That said, if you're using
serverSide
, it's entirely up to that server script to return whatever it wants, so you could add that logic in there.Colin
Only the total length is I'm getting from the server side. If I can get the total length in datatable options it would be much better and I can load that.
Does this example do what you want?
http://live.datatables.net/buriciwe/1/edit
You will want to look at the
page.info()
API docs.Kevin
Yeah but I want to show only the number of records. I want to hide pagelength options. Is that possible?
You can customize the display as you want.
Use the
lengthChange
option to remove the page length input.Kevin
Yeah it worked. Thank you kevin