DataTables.NET Paging Counts Incorrect when using Server Side Data
DataTables.NET Paging Counts Incorrect when using Server Side Data
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:
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
wow typo
recordsFilter
in the Ajax response should berecordsFiltered
and now it worksCan 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
@allan - yes, the issue was with me returning
recordsFilter
in the results instead of the correct valuerecordsFiltered
.