Datatables server side processing how to intercept json response and call an action
Datatables server side processing how to intercept json response and call an action
Hello,
I need help with a data table that needs server side processing. I am using an MVC app . The example that I am testing on works find it sends the data from the data table to an action and the action does the filtering and sorting and sends a JSON response that is then use to render the table again.
What I need is to have the json response not be used as the rendering source but instead call another action and send the json as parameter and have the action do the work.
$(document).ready(function () {
$('#myGrid').DataTable(
{
"processing": true,
"serverSide": true,
"ajax": {
"url": "../DataT/sproc/",
},
"columns": [
{ "data": "SalesOrderID" },
{ "data": "SalesOrderDetailID" },
{ "data": "CarrierTrackingNumber" },
{ "data": "OrderQty" },
{ "data": "ProductID" },
{ "data": "UnitPrice" }]
}
);
})
So I need some sort of way to have a call back function that runs on success how can I do that?
Answers
It looks that I will need a complete option as show below:
"ajax": {
url: "calendar_ajax.aspx?method=showrecurringevents_load&method=showrecurringevents&id=0&id2=0&newvalue=&cal_id=3188&t=1455268695315&coreid="
, dataType: "json"
, complete: function() {
paintcheckboxes("recurringtable")
}
, error: function (xhr, error, thrown) {
alert("An error occurred while attempting to retrieve data via ajax.\n"+thrown );
}
, }
But on top of that I need a way to prevent ajax to load the return values and instead let the action take over the rendering part
here is a stub, based on some stuff I did a while ago, that my get you headed in the right direction.
Thank you for your response.
I will have to parse through your answer carefully to catch up .