我尝试使用以下代码填充jQuery DataTable:
的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" }
]
});
});
我的控制器:
public ActionResult GiveUpView()
{
var result = GiveUpRepository.Instance.GetGiveUp();
return Json(result.Take(10).ToList(), JsonRequestBehavior.AllowGet);
}
我在chrome调试中检查过响应是在Json中出现的,如下所示:
[{"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"}]
但数据表一直显示处理... 。另外,在cshtml中有一个带有id="giveUps"
的HTML表。
我错过了什么?
修改
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] },
...
]
});
});`
它工作正常,但时间没有显示为dateTime,而是显示为字符串/日期(1471982820000)/任何sugestions?