Unclear on obtaining table data from a RESTfull API
Unclear on obtaining table data from a RESTfull API
My table works like a champ with a small dataset but now I need to access the real thing (100K+ records) using a provided RESTful API.
The API supports fetching data using this format:
serveraddress/api/locations?limit=100&offset=0
So my plan was to fetch results 100 at a time. The DataTables documentation says that in order to do this, I need to also send the site a bunch of other parameters (iDisplayLenght, iDisplayStart, iColumns, sEcho, etc. etc.)
Is that correct or can I just reload my table using an API call like: serveraddress/api/locations?limit=100&offset=100 instead?
If so, how do I detect when the table needs to load a new set?
If anyone knows of an example that deals with a simmilar situation it would be a huge help!
Thanks
The API supports fetching data using this format:
serveraddress/api/locations?limit=100&offset=0
So my plan was to fetch results 100 at a time. The DataTables documentation says that in order to do this, I need to also send the site a bunch of other parameters (iDisplayLenght, iDisplayStart, iColumns, sEcho, etc. etc.)
Is that correct or can I just reload my table using an API call like: serveraddress/api/locations?limit=100&offset=100 instead?
If so, how do I detect when the table needs to load a new set?
If anyone knows of an example that deals with a simmilar situation it would be a huge help!
Thanks
This discussion has been closed.
Replies
However, unless the API allows you to provide parameters for filtering and sorting, you will be unable to perform those functions in your DataTable. In addition, you'll have to somehow workaround the lack of sEcho support.
Regarding sEcho - it isn't a mediatory parameter, you can do without it - but it can be useful for when the server has a heavy load on it, since it prevents data requests being drawn out of sequence.
There is one more option - rather than using server-side processing, you could use client-side processing and load the data in chucks. i.e. set up a loop that makes a request every 500mS for 1000 more records and use the DataTables API to add the new data to the table. I'd generally recommend against this as server-side processing is hugely more efficient, but if you are constrained by the REST API, it might be the only way.
Regards,
Allan