Set a limit of records returned through API request?

Set a limit of records returned through API request?

SnacklesSnackles Posts: 10Questions: 2Answers: 0

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!

Answers

  • colincolin Posts: 4,648Questions: 0Answers: 815

    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

  • SnacklesSnackles Posts: 10Questions: 2Answers: 0

    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!

  • SnacklesSnackles Posts: 10Questions: 2Answers: 0

    I found a temporary solution using the Where Conditions in my controller.

    .Where(q => q.Where("Writeoffs.writeoffdatetime", "DATEADD(year, -1, GETDATE())", ">=", false))
    

    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.

  • allanallan Posts: 49,486Questions: 1Answers: 7,278 Site admin

    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

Sign In or Register to comment.