Server-side | customize pagination

Server-side | customize pagination

mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0
edited October 2022 in Free community support

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: Greetings, I hope you are very well.
Currently I am using datatables to display data in a table but I realized that the data was growing and the loading of the table is getting slower. I would like to rely on the server-side property so that in each sheet, it queries the server for the data of that second sheet and so on. I'm trying to do it but he always asks me about the same page. Can you help me to personalize my ajax url and be able to send the sheet number?

This question has accepted answers - jump to:

Answers

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

    That's not how server-side processing is configured. For server-side processing, enable serverSide. The protocol is discussed here. Also see examples here. If you download the DataTables repo, there are examples of the server-side scripts here,

    Cheers,

    Colin

  • mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0

    Unfortunately I had not read the documentation correctly.
    Now, after reading, I am relying on the "draw" property to configure my server and return the information of the corresponding page.
    Thanks a lot.

  • mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0

    Sorry, I still have the problem.
    How can I tell the server which page is next?
    If I use the "draw" property, it keeps increasing but if I go back in the pages, "draw" keeps increasing.
    I need to know which is the next page to fetch that information from the server.

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited October 2022 Answer ✓

    The draw property is a sequence number not a page number. The Server Side Processing protocol describes the start and length parameters which tell the server script the page to fetch. You can derive the 0 based page number, in your server script, from these parameters like this page = start / length.

    Or you can use a Datatables supplied server side processing script. See this blog describing how to use them.

    Kevin

  • mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0

    Thank you very much. I came to that conclusion lol.

  • mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0
    edited October 2022

    so i left it

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited October 2022 Answer ✓

    You might be able to simplify the code into one statement:

    page = ( int(data['start']) / int(page['length'] ) + 1
    

    Glad you got it working though :smile:
    Kevin

  • mllumiquinga194mllumiquinga194 Posts: 7Questions: 1Answers: 0
    edited October 2022
        page = int(data["start"])
        per_page = int(data["length"])
        page = page / per_page + 1
    

    finally it was like this. Thanks, you're a crack

Sign In or Register to comment.