The main problem is that data tables does not expect a list of objects, instead it wants a differently formatted json object, something like
data: {“Property”: Value}
etc
Instead it’s getting a pure list, like this
[
{“Name”:”Value},
{“Name”:”Value},
{“Name”:”Value},
{“Name”:”Value},
{“Name”:”Value},
]
Solution – list out the values in the columns property of the data table, like this
$(document).ready(function () {
$(‘#example’).dataTable({
“deferRender”: true,
“processing”: true,
“iDisplayLength”: 25,
“ajax”: {
“url”: “https://domain.com/Ajax/v1.1/ListTypes”,
“dataSrc”: “”
},
“columns”: [
{ “data”: “Name” },
{ “data”: “OtherColumn” }
]
});
});
And you’re done!
|
Written By Steve French |
Leave a Reply