Pagination buttons active before table completed

Pagination buttons active before table completed

awarnockawarnock Posts: 13Questions: 3Answers: 0

I have a table instance which can return a lot of records (hundreds to thousands), and can take a long time to render, so I'm doing server-side pagination on it. It's working fine except for one small issue.

When the table first renders, it shows the link buttons for all of the pages, but the links are active before the code fetches all of the pages. As a result, it's possible to click on the link for the last page (or any intermediate page) before that page has loaded. I can watch the update requests in the browser console.

What happens is that the display silently goes back to the first page instead of displaying the requested page - not unreasonable but pretty confusing for the end users who don't know why they click the button for, say, page 18 and wind up back at page 1.

Is there some way to disable the page buttons until the relevant page has loaded, and then activate them as each page is retrieved from the server?

Many thanks!

This question has an accepted answers - jump to answer

Answers

  • awarnockawarnock Posts: 13Questions: 3Answers: 0

    As an alternative, is there an event which fires when the user clicks on a page button? If so, I guess I could watch for it and manually send the Ajax request to the server for the corresponding page and then display it.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    It sounds to me like your script is returning all the records, which is why you're seeing that delay when the user can click on the paging. If it's just 100s to 1000s of records, you should really need serverSide - that should only be needed when you've for 10ks of records or above.

    You can try processing, but if that doesn't work, I'd say there's something wrong with your server-side script. If you link to your page, we can take a look.

    Colin

  • awarnockawarnock Posts: 13Questions: 3Answers: 0
    edited August 2021

    Thanks. In the browser console, I can see it retrieving each page in background. I'm not sure what option would defer loading the page until the page number button is selected.

    This particular application is behind a firewall, so I can't link directly. The table can be anywhere from a few to tens of thousands of records, so I'm already using serverSide option, and have the back end script pulling the parameters from the database to return just one page worth of results.

    I did look at the processing option. It only controls the processing indicator, right? Anyway, I changed it from 'true' to 'false' and it didn't make any difference.

    I guess I need to dig into why the Ajax calls are running through all of the pages instead of just retrieving the selected page. Thanks for the suggestions.

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    When you say you are doing server-side paging do yo mean you have the serverSide option enabled?

    Here is a running example of server side processing that shows how serverSide processing works.

    Kevin

  • awarnockawarnock Posts: 13Questions: 3Answers: 0

    Yes - I have the serverSide option enabled.

    I'm looking now at possible page refreshes which might be triggering the table to reload from scratch at the same time the individual pages are loading. That would certainly confuse things. I have some dynamic elements on the page that I thought were refreshing independently, but it's behaving like one of them is refreshing the whole page. It may turn out to not be an issue with DataTables after all.

    But thanks for the pointers. They've been helpful in sending me in the right direction.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    I think it would help if we could see this. Could you link to your page, please, so we could take a look,

    Colin

Sign In or Register to comment.