Datatable pagingation - server side - MVC - can I get pagination to work without counts?

Datatable pagingation - server side - MVC - can I get pagination to work without counts?

hsbeaumierhsbeaumier Posts: 3Questions: 1Answers: 0

Hi,

I am using Datatables with pagingation, server side, with ASP.NET MVC.

Can I get pagination to work without counts? All I really need is the back and next buttons with current page. It seems that counts are required in the JSON response for this to work. Is there any way around the counts?

The reason for avoiding the counts is that we have millions of records, and our tables keep growing. We are working on a better solution for the database, but regardless we have a high volume and running a count on the query results before and after filter would kill performance.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @hsbeaumier ,

    There's several alternatives for the paging style - this example here should get you going,

    Cheers,

    Colin

  • hsbeaumierhsbeaumier Posts: 3Questions: 1Answers: 0

    Thanks @colin

    But paging style is not the issue. The issue is that the JSON response for server side processing requires counts, regardless of the paging style. Not sure why, I guess there is only one standard JSON response type for server side processing via AJAX post. I am trying to fake something for now, but long run we can't run counts just to get the page next and back to work. I tried supplying no counts, but it failed and would not work without some sort of count. The reason why we can't supply counts is due to the volume of those tables being too large. Tens of millions and growing...

  • hsbeaumierhsbeaumier Posts: 3Questions: 1Answers: 0

    I tried looking into efficient counts solutions, but most of the ones I have seen don't encompass counts for constructed queries. Maybe counts at the table level via one of the system views, but not at the query level.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @hsbeaumier ,

    I see what you mean. You may be able to get away with just setting these two to something high:

      "recordsTotal": 500,
      "recordsFiltered": 500,
    

    I suspect if they're high everything should work. The get used in the information section of the table, so you would need to disable that with dom as they make no sense with fake values.

    The other thing to bear in mind is that draw needs to increment with each response.

    Cheers,

    Colin

This discussion has been closed.