I'm trying to populate a jQuery DataTable using the code below:
Javascript
$(document).ready(function () {
var data = $('#giveUps').DataTable({
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/GiveUp/GiveUpView",
"aoColumns": [
{ "type": "text" },
{ "type": "number-range" },
{ "type": "number-range" },
{ "type": "number-range" },
{ "type": "text" },
{ "type": "text" },
{ "type": "number-range" },
{ "type": "text" },
{ "type": "number-range" },
{ "type": "text" },
{ "type": "text" },
{ "type": "number-range" },
{ "type": "number-range" },
{ "type": "text" },
{ "type": "date-range" },
{ "type": "text" },
{ "type": "text" },
{ "type": "number-range" },
{ "type": "text" },
{ "type": "text" }
]
});
});
My controller:
public ActionResult GiveUpView()
{
var result = GiveUpRepository.Instance.GetGiveUp();
return Json(result.Take(10).ToList(), JsonRequestBehavior.AllowGet);
}
I checked in the chrome debug that the response is coming int the Json as bellow:
[{"AId":"T-2-1471982820928-7","TInfo":382010,"Seg":1,"Mar":10,"Cod":"X","Nick":"BILL","Account":203627,"SecondNick":"XXX","Origin":203627,"Name":"Test","Up":"Yes","Quantity":300,"Price":12.87,"Number":"54360","GiveUpDateTime":"\/Date(1471982820000)\/","Status":"APPROVED","Desk":"","OffHours":1541,"ErrorDescription":"","Key":"T-2-1471982820928-7|382010"}]
But the datatable keeps showing Processing.... Also, there is an HTML table with the id="giveUps"
in the cshtml.
What am I missing?
EDIT:
I change the function for the following:
$(document).ready(function () {
var data = $('#giveUps').DataTable({
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/GiveUp/GiveUpView",
"aoColumnDefs": [
{ "mDataProp": "AId", "aTargets": [1] },
{ "mDataProp": "TInfo", "aTargets": [2] },
{ "mDataProp": "Seg", "aTargets": [3] },
{ "mDataProp": "Mart", "aTargets": [4] },
{ "mDataProp": "Cod", "aTargets": [5] },
...
]
});
});`
It's working fine but the time is not showing as dateTime but as string /Date(1471982820000)/ any sugestions?