Set a limit of records returned through API request?
Set a limit of records returned through API request?

Hello,
I have an ASP.NET MVC web app that uses API requests to send and receive records from an SQL server. On one particular table, there are over 80,000 records; however, I don't need all 80,000 records. Is there a way to only grab the top 10,000 records or set some kind of limit on the number of records returned?
Thank you!
This discussion has been closed.
Answers
Hi @Snackles ,
Given your question, I suspect you haven't tried
serverSide
- for that number of records, it is recommend. There, only the required records needed for that display are returned,Cheers,
Colin
Hey Colin,
Yeah, that's kind of what I figured I should do. I'm just struggling to under the documentation for serverSide processing. I'm pretty new to this stuff and don't have as much time as I'd like to spend on it. Most examples seem to reference using PHP? Is that necessary? Can I just use my current API and ajax?
Thanks for the response!
I found a temporary solution using the Where Conditions in my controller.
In regard to implementing server-side processing in an ASP.NET MVC web app. I set "serverSide": true and I did get a response from the server after a few minutes of waiting. I'm just struggling to figure out how to set the "Sent parameters" like Draw, Length, Searchable mentioned on the Server-side processing manual webpage: https://datatables.net/manual/server-side.
If you enable
serverSide
then those parameters will be sent to the server automatically.One option would be to use the Editor .NET libraries which support server-side processing natively. You don't need an Editor license to use them, the .NET part is open source although you would need to use the Editor documentation to make use of them.
If you search the web you'll find a number of others have also written on the topic of using DataTables with server-side processing - e.g. this YouTube clip.
Allan
Hey Allan,
I've watched that YouTube video before, but it's a bit confusing because my controller looks nothing like that - I used the generator on this site.
I noticed at the top of the controller in that video, that they declared variables like displayLength, displayStart. I don't have varaibles declared like that and in my API response draw is null and recordsTotal and recordsFiltered aren't being returned.
Should I declare the variables like what I did for int recordsTotal in my controller below? It's commented out at the moment.
Hi @Snackles ,
For server side processing, the protocol is discussed here. It would also be worth looking at the examples to see what's sent and what's expected in the response.
Cheers,
Colin