这是我获取数据的动作结果。我不知道为什么一切都很好看。
public ActionResult loadProjectData()
{
var data = harvestApi.GetAllProject2().OrderBy(a => a.created_at).ToList() ;
return Json(new { data = data }, JsonRequestBehavior.AllowGet);
}
这是我的DataTable功能
$(document).ready(function () {
$('#myTable').DataTable({
"ajax": {
"url": "/project/loadProjectData",
"type": "GET",
"datatype": "json",
},
"iDisplayLength": 100,
"columns": [
{
"data": "harvestLink", "autoWidth": true, "bSortable": true, "mRender": function (data, type, full) {
return '<a targevt="_blank" href=' + data +
'>' + full.name + '</a>';
}
},
{
"data": "Client_Id", "autoWidth": true, "bSortable": true, "mRender": function (data, type, full) {
return '<a target="_blank" href=' +
'@Url.Action("Customercard", "Customer")?id=' + data +
'>' + full.c+ '</a>';
},
},
]
});
});