How to check whether it is the final page?

How to check whether it is the final page?

HarfordHarford Posts: 6Questions: 0Answers: 0
edited July 2009 in General
Dear Sir,

Here, I want to get more records from server when the user is at the final page, how should i know whether the user is at the final page?

How to implement this? Is there any event to fire when the user is at the final page?

Thank you so much!

Replies

  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    Hi Harford,

    If the user is on the final page, what more records are there to get?! Regardless, yes it is possible. You can use the fnHeaderCallback() function to find out when the user is on the last page: http://datatables.net/usage#fnHeaderCallback

    This function passes a number of parameters, including the display array and the start and end of the current display. If the end index matches the length of the array - then it's showing the last page.

    Hope this helps!

    Regards,
    Allan
  • HarfordHarford Posts: 6Questions: 0Answers: 0
    Thank you so much!

    Because there are too many records in the server. So at first time, I only get the first 200 of the records from the server to show in the DataTables. When the user is at the final page of the first 200 records, I'll get another 200 from the server.

    That's my case.

    Thanks for you response. I'll try it.
  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    Hi Harford,

    If you are running into problems with loading large amounts of data in one go, it might be worth looking at the server-side processing option in DataTables. See http://datatables.net/1.5-beta/examples/data_sources/server_side.html for an example.

    Regards,
    Allan
  • HarfordHarford Posts: 6Questions: 0Answers: 0
    Dear Allan,

    Thank you so much!

    I think I can use the server-side method to resolve my problem. Is this function new in 1.5beta?
  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    Hi Harford,

    Yes, server-side processing is the 'big new feature' in DataTables 1.5. A lot of little other things as well, but this is the main one. :-)

    Allan
This discussion has been closed.