DataTables.NET Paging Counts Incorrect when using Server Side Data

DataTables.NET Paging Counts Incorrect when using Server Side Data

mlb5000mlb5000 Posts: 3Questions: 1Answers: 0

I have a jQuery DataTables (v 1.10.4) table configured like this:

$('#example').dataTable({
                "serverSide": true,
                "order": [0, "asc"],
                "ajax": { url: "/api/users?type=all", dataSrc: "users" },
                "columns": [
                    { "data": "Name" },
                    { "data": "Dob" },
                    { "data": "Gender" }
                ]
            });
        });

My server returns the following from the Ajax call (not valid JSON, just copied from Chrome):

    draw: 1
    users: [{Id: "5b54b4a0-d1ad-4f0b-80a4-5fff6d6a74af", Name: "DOE, JOHN", Dob: "19371127", Gender: "M",…},…]
    recordsFilter: 287
    recordsTotal: 287

This includes the required return fields as described in the DataTables.NET documentation, but for some reason the paging numbers render incorrectly:

enter image description here

The rest of the table renders and functions just fine, aside from the "Prev..." and "Next..." buttons being disabled (I assume because it thinks there are 0 results). Has anyone encountered this issue before?

(also on StackOverflow)

Answers

  • mlb5000mlb5000 Posts: 3Questions: 1Answers: 0
    edited December 2014

    wow typo

    recordsFilter in the Ajax response should be recordsFiltered and now it works

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Can I just check - this is with your own .NET server-side implementation, rather that with Editor's? Editor's .NET library appears to be behaving correctly in this regard.

    Thanks,
    Allan

  • mlb5000mlb5000 Posts: 3Questions: 1Answers: 0

    @allan - yes, the issue was with me returning recordsFilter in the results instead of the correct value recordsFiltered.

This discussion has been closed.