我在我的视图中使用了 jQuery Datatable,如下所示;
<table id="CategoryGrid">
<thead>
<tr>
<th>Id</th>
<th>
Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
以及 Datatable 的 javascript 代码;
var catGrid = $('#CategoryGrid').dataTable({
"bPaginate": true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "@Url.Action("CategoriesGet")",
"aoColumns": [
{
"sName": "CategoryId",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '<a href=\"Company/Details/' + oObj.aData[0] + '\">View</a>';
}
},
{ "sName": "CategoryName" },
{ "sName": "CategoryDescription" }
]
});
返回的JSON数据如下;
{"sEcho":"1","iTotalRecords":10,"TotalDisplayRecords":10,"aaData":[["1","For Sale","asdfasdf"],["2","Jobs","asdfasdfasdf"],["3","Classes","asdfasdf"],["4","Vehicles","asdfasdsadfa"],["45","test","asdff"],["46","asfd","sdf"],["47","test","sdf"],["48","another test","sfsdfsdf"],["49","another test","sdfsdfsdf"],["50","asfd","asdf"]]}
为什么我在 NaN 条目中显示 1 到 NaN