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: 8,931Questions: 25Answers: 2,040

    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: 8,661Questions: 0Answers: 1,449

    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: 8,931Questions: 25Answers: 2,040

    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: 8,931Questions: 25Answers: 2,040
    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

Sign In or Register to comment.