datatable pagelength

datatable pagelength

naveenramnaveenram Posts: 8Questions: 3Answers: 0

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

Answers

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    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

  • naveenramnaveenram Posts: 8Questions: 3Answers: 0

    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';
    }

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    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

  • naveenramnaveenram Posts: 8Questions: 3Answers: 0

    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.

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736

    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

  • naveenramnaveenram Posts: 8Questions: 3Answers: 0

    Yeah but I want to show only the number of records. I want to hide pagelength options. Is that possible?

  • kthorngrenkthorngren Posts: 20,145Questions: 26Answers: 4,736
    Answer ✓

    Yeah but I want to show only the number of records.

    You can customize the display as you want.

    I want to hide pagelength options. Is that possible?

    Use the lengthChange option to remove the page length input.

    Kevin

  • naveenramnaveenram Posts: 8Questions: 3Answers: 0

    Yeah it worked. Thank you kevin

This discussion has been closed.