JQuery DataTables .Net Server Side Pagination Issues

前端 未结 1 990
独厮守ぢ
独厮守ぢ 2020-12-15 19:51

I\'m working on a bug fix right now for an application at work where the prior developer (since gone) didn\'t bother to paginate the data results on a page meant specificall

相关标签:
1条回答
  • 2020-12-15 20:04

    Your iTotalDisplayRecords is equal to 25, so datatables think that there are only 25 contracts on the server side and second page is not needed because all of them are already shown on the current page. This is comon mistake - if you take a look at the JQuery MVC tutorial section Implementation of server-side paging you will see that there are three numbers:

    1. iTotalRecords = allCompanies.Count() representing all entries in the database (in your case 2086)
    2. iTotalDisplayRecords = filteredCompanies.Count() representing the number of the records that match the current search condition. If you didn't used filtering this number should be same as the iTotalRecords 2086, but in yourcase it is 25.
    3. result.Count - this is 25. This number is not passed in the JSON response because DataTables already knows that there should be 25 records per page.

    If you put all.Count insteadof the result.Count into the iTotalDisplayRecords DataTables will show paging. iTotalDisplayRecords and iTotalRecords are used to show message "Showing 1 to 25 of iTotalDisplayRecords (iTotalRecords in total)"

    If iTotalDisplayRecords is equal to 25, DataTables will show message "Showing 1 to 25 of 25 (iTotalRecords in total)", and assume that there is no page 2; hence, paging will be disabled, as in your example.

    Jovan

    0 讨论(0)
提交回复
热议问题