Pagination 'Last' button when chunking data

Pagination 'Last' button when chunking data

rjconradrjconrad Posts: 4Questions: 0Answers: 0
edited August 2013 in General
Hello everyone,

I am having trouble figuring out how to make the full_numbers pagination example to display and work correctly when using the 'Last' button. I am chunking data of 100 entries, where each page shows 25 results.

I also use the information of the 'Showing 1 to 25 of 2000000' entries and I wish to make that display correctly too.

I cannot load all of the data as I go because there is way too much, so does anyone have any ideas or solutions they have found to accomplish this?

Thank you!

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Use server-side processing perhaps? That will cope with millions of records.

    Allan
  • rjconradrjconrad Posts: 4Questions: 0Answers: 0
    No I am, but the problem is that when I hit the last page button, it will go to 100 and say "Showing 79 to 100 of 16000 entries' because all the records that are loaded is 100 records. When I hit the Last button currently it just will chunk the next 100 and you will need to hit the last button a ton of times to get to the end of the records.

    I want to have it so I can still chunk, but also have the last button able to just go to the last page, and have all the page numbers and 'Showing' correct, eventhough there is a gap say of what is loaded in the table. So I would have pages 1 to 4 loaded, then I hit Last and I would then have 1 to 4 and say 30 to 34, but I dont want the pagination control displays to mess up.

    Do you think this is even possible? Or should I just load the 25 for each page everytime I hit a different page?
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    This example shows chunking with server-side processing: http://datatables.net/release-datatables/examples/server_side/pipeline.html

    Allan
  • rjconradrjconrad Posts: 4Questions: 0Answers: 0
    So I think I have a better way of explaining it because I have a possible solution in mind but not sure how to do it with DataTables.

    To not have to write crazy last button logic and so forth as I was talking about. It would be easier I think to keep the Last button the way it is, and instead FILL IN the gap between the few pages of loaded data and the loaded data of the last page with empty rows.

    So my question is: Is there a way to either have Datatables think it has like 400 rows then it only actually have 100 loaded for example. Or otherwise, how would I insert in empty rows and not have the table sort them which would corrupt the loaded data pages, and I will just fill in the empty rows with real data as the use pages.

    Thanks allan
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    > So my question is: Is there a way to either have Datatables think it has like 400 rows then it only actually have 100 loaded for example

    Yes. In the example I linked to above ten rows are shown per page, but it has actually loaded 50 records, and will load more if needed (i.e. going page the 50th record). It has loaded 50 client-side, but as you'll see there are 57 in the table.

    Allan
  • rjconradrjconrad Posts: 4Questions: 0Answers: 0
    So in that example does the oCache help keep the dataTables_info up to date, because even when you see the 50-57, the table only has 7 things in total loaded, but because of the Cache the info shows correctly?

    Is that right? Not sure how the inner workings of Datatables work for that.
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    That's more or less the gist of it - yes :-). The caching code is a layer between DataTables and the server, to try and reduce the number of ajax requests needed by DataTables. Obviously sorting and filtering will invalidate the cache, but for simple pagination it will reduce the number of requests.

    Allan
This discussion has been closed.