1
votes

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?

1
show us your controller end return something like return json(//bkah blah - super cool
@supercool why is the return statement important if I showed you what came back to the browser? - Matt Baker
becoz in your json return you may have something like iTotalDisplayedRecords which decides how many pages required to generate pagination . i am just guessing here . - super cool
@supercool no, the entire contents of my Ajax return are above. All I return are 'draw', 'recordsFilter', 'recordsTotal', and my results (pointed to by 'dataSrc' in the configuration) - Matt Baker
@supercool ugh, after typing it incorrectly for the 487th time, recordsFilter should be recordsFiltered. Getting this wrong breaks the paging counter. - Matt Baker

1 Answers

0
votes

recordsFilter in the Ajax response should be recordsFiltered.