How do I do this in DataTables?

How do I do this in DataTables?

RonWesleyRonWesley Posts: 2Questions: 1Answers: 0

which I am trying to use in conjunction with an extremely large data source (upwards of 1,000,000 records). In my web application, I have an API that can call on this information, we'll just call it mysite.com/ajaxCall. It returns an array in the formatI have built the API to accept a number of URL parameters, including limit and offset (functioning exactly as their SQL commands), and sortAsc and sortDesc accepting column names.

What I want to implement is have Datatables call only the data it needs from /ajaxCall to display immediately. as opposed to calling all data at once and making the application unusable. I've included a mockup of examples of that in action

Answers

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765

    You can use server side processing. The linked doc explains the protocol it supports. Maybe you can adapt your API to support the parameters.

    Kevin

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Hi,

    With that many records you are going to want server-side processing which does as you are looking for, request just the data that needs to be displayed for the current DataTables page (i.e. 10 rows).

    The way server-side processing works is that DataTables sends a bunch of information to the server to say "I need rows X to Y, with this ... ordering and this ... search". The parameters DataTables sends are documented on the page I linked to above.

    If those parameters don't match what your server implements there are two options:

    1. Use preXhr or ajax.data to modify the default parameters into the parameters you want to send.
    2. Modify the server-side code to accept the DataTables default parameters.

    In reply DataTables expects JSON with a little extra information about the number of records in the table, etc - which is also documented on that page.

    Allan

  • RonWesleyRonWesley Posts: 2Questions: 1Answers: 0
    edited January 2020

    which I am trying to use in conjunction with an extremely large data source (upwards of 1,000,000 records). In my web application, I have an API that can call on this information, we'll just call it mysite.com/ajaxCall. It returns an array in the formatI have built the API to accept a number of URL parameters, including limit and offset (functioning exactly as their SQL commands), and sortAsc and sortDesc accepting column names.
    What I want to implement is have Datatables call only the data it needs from /ajaxCall to display immediately. as opposed to calling all data at once and making the application unusable. I've included a mockup of examples of that in action

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    For anyone else reading this thread, there were spam links in the reply and no direct response to my comments above.

    Allan

This discussion has been closed.