Datatable Not Sorting After Ajax Call
Datatable Not Sorting After Ajax Call

Hello everyone and thanks for your help in advance. I am new to datatable. I am populating at datatable with JSON data from a WebAp2 controller. I have the datatable populating correctly, however, all of the sort and search functionalities stopped working. Additionally, the paging buttons show multiple pages even though I am currently only returning 4 records. Here is my code:
'''
$('#myAjaxTable').DataTable(
{
"processing": true,
"serverSide": true,
"sortable": true,
"ajax": "../api/Claim/GetUnpaidClaims",
"columns": [
{ "data": "MRNumber" },
{ "data": "FirstName" },
{ "data": "LastName" },
{ "data": "DOB" }
]
}
);
});
'''
I am assuming this has to do with the DOM of the table being populated after the datatable is declared, but I am not sure how to fix this. Any help would be appreciated.
Replies
When your running serverside its up to you to do the sorting/paging etc.
You must also return the correct data - eg recordsTotal etc..
Read this link https://datatables.net/manual/server-side
In particular look at what the server is supposed to return.
etc